SWT/AWT的问题:怎样在listener中访问其他控件?
照着例子写的,还会出错.....请高手指点!!
原代码:
Display display = new Display ();
Shell shell = new Shell (display);
Label label = new Label (shell, SWT.CENTER);
...
shell.addControlListener (new ControlAdapter () {
public void controlResized (ControlEvent e) {
label.setBounds (shell.getClientArea ());
}
});
出错信息:
java.lang.Error: Unresolved compilation problem:
Cannot refer to a non-final variable label inside an inner class defined in a different method