I have some problem with JButton
action events, I have declared a global variable (boolean tc1
) and a JButton t1
. When I press the JButton I need to change the value of the boolean variable to 'true'. Can any one help me out? My code goes here.
class Tracker extends JPanel {
public static void main(String[] args) {
new Tracker();
}
public Tracker() {
JButton tr=new JButton("TRACKER APPLET");
JButton rf=new JButton("REFRESH");
boolean tc1=false,tc2=false,tc3=false,tc4=false;
JButton t1=new JButton(" ");
t1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
tc1=true;
}
});
System.out.println(tc1);
//remaining part of the code...
// here i need to use the value of tc1 for further process..
}
}
Thanks.