2012-06-10 3 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 .. 
    } 
} 

당신이 방법 foo()에 대한 호출이있는 addSelectionListener 내에서 볼 수 있듯이.

제 질문은 - 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 그.

관련 문제