这样就不能使用匿名内部类来定义这个ActionListener了,可以定义一个内部类甚至普通类来实现,如:
class ActionHandler implements ActionListener {
private String[] args;
// setter and getter
public ActionHandler(String[] args) {
this.args = Arrays.copyOf(args, args.length);
}
@Override
public void actionPerformed(ActionEvent e) {
// ...
}
}
把那个数组定义为类的static变量才可以