5

フォロークラスを持っている -

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ように、 method への呼び出しがありfoo() ます。

foo()私の質問は、どのクラスがfoo()に関連しているかを知るために、接頭辞としてどの参照を書くべきかということです。

私はsuper().foo()成功しなかった。

4

2 に答える 2

8

あなたはそれを次のように呼ぶでしょうGUIclass1.this.foo()

于 2012-06-10T14:49:12.050 に答える
0

これを試して、

私たちが知っているようにan inner class has an implicit access to the members of the outer class、そうthis.foo() Will NOT work、しかし

GUIclass1.this.foo() Will WORK.

于 2012-06-10T14:55:43.203 に答える