请大家看看这个错误
我写的按扭监听事件,label声明为成员变量,但是出错了!这是为什么呢?
button.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
ImageIcon imag=new ImageIcon("6.jpg");
label.setIcon(imag);
}
}
);
D:\>javac PictureView.java
PictureView.java:59: local variable label is accessed from within inner class; n
eeds to be declared final
label.setIcon(imag);
^
1 error