有跟随类-
public class GUIclass1 extends org.eclipse.swt.widgets.Composite {
private void initGUI() {
{
// The setting of the open file button.
openButton = new Button(this, SWT.PUSH | SWT.CENTER);
openButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
foo() ;
}
});
}
}
public void foo() {
// implementation ..
}
}
如您所见,在 addSelectionListener
中调用了方法 foo()
。
我的问题是 - 我应该写哪个引用作为 foo()
的前缀,以便知道哪个类 foo()
与 相关。
我尝试了 super().foo()
但没有成功。
最佳答案
您可以将其称为 GUIclass1.this.foo()
关于java - 从监听器调用所有者类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10969640/