【发布时间】:2013-02-01 07:05:53
【问题描述】:
JButton 动作事件有一些问题,我已经声明了一个全局变量 (boolean tc1) 和一个 JButton t1。当我按下 JButton 时,我需要将布尔变量的值更改为“true”。谁能帮我吗?我的代码放在这里。
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..
}
}
谢谢。
【问题讨论】:
-
你的代码有什么问题?什么不工作?
标签: java swing jbutton actionevent