2012-06-10 26 views
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內看到有一個呼召方法foo()

我的問題是 - 我應該寫哪個參考作爲前綴foo()以便知道哪些類foo()與哪些類相關。

我試過super().foo()沒有成功。

回答

8

你會稱呼其爲GUIclass1.this.foo()

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