从监听器调用所有者类

URL*_*L87 5 java methods swt button listener

有以下课程 -

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 ..
    }
}
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,addSelectionListener有一个调用方法foo() .

我的问题是 - 我应该写哪个引用作为前缀foo(),以便知道哪个类foo()与之相关.

我试过super().foo()没有成功.

Ale*_*s G 8

你会称之为 GUIclass1.this.foo()