可以向匿名类传递参数或访问外部参数吗?例如:
int myVariable = 1;
myButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// How would one access myVariable here?
}
});
有没有办法让侦听器访问myVariable或传递myVariable,而不将侦听器创建为实际的命名类?
https://stackoverflow.com/questions/5107158
复制相似问题