请问在swing中,怎样把参数传递到事件处理中?
请问在swing中,怎样把参数传递到事件处理中?
例如:
JButton b_save=new JButton("保存");
String var="hello"; //怎样把这个var变量传递到 save 事件程序里面?
b_save.addActionListener(save);
static ActionListener save = new ActionListener(){
public void actionPerformed(ActionEvent ae) {
try {
System.out.println(var); // 怎样将var变量传入到这里???
} catch (Exception e) {
e.printStackTrace();
}
}
};