2012-10-01 2 views
0

내가 더 잘하는 것에 대해 설명해 드리겠습니다. baseDialog.startPrintOperation() 방법이 완료되면SWT - 다른 클래스의 대화 상자 창 닫기

메인 GUI 내가 대화 A를 닫으려면, 열 때 클릭 정보 대화 대화 A의 OK 버튼을 눌러 메인 GUI

public void widgetSelected(SelectionEvent e) { 
     baseDialog.startPrintOperation(); 
} 

에서 메소드를 실행하는 버튼이 있습니다.

대화 상자를 다른 클래스의 메서드에서 닫으려면 어떻게해야합니까?

EDIT 여기

대화 A의 okButton은 여기

okButton.addSelectionListener(new SelectionAdapter() { 
    @Override 
    public void widgetSelected(SelectionEvent e) { 
     getPlotterSelection(); 
     getSpinnerValue(); 
     Runnable r = new Runnable() { 
      public void run() { 
       baseDialog.startPrintOperation(); 
      } 
      }; 

      if(Display.getCurrent() != null) { 
      r.run(); 
      } 
      else { 
      Display.getDefault().asyncExec(r); 
      } 
     } 
    }); 

이 방법은 MAIN GUI 클래스에 대화 A.를 닫을 필요가 printOperation 방법의 단면

finally { 
      plotOp.removeOperationListener(this); 
      plotOp = null; 
      Display.getDefault().asyncExec(new Runnable() { 
       public void run() { 
       removeAllTableRows(); 
       plotRequestCompleted = true; 
       THIS is where I want to close Dialog A; 
       } 
      }); 
     } 
    } 
    }); 
    session.queueOperation(plotOp); 

} // end startPrintOperation()

답변

1

인쇄 호출이 완료되면 Dialog.public boolean close()을 호출하십시오.

+0

죄송합니다. 제안을 따르지 않겠습니다. – jkteater

+0

Pls는 Dialog.close() 메서드를 사용하여 대화 상자를 닫습니다. 대화 상자에서 okPressed() 메서드를 재정의하고 okPressed() 메서드에서 인쇄 작업을 호출합니다. –

+0

위의 편집을 참조하십시오. – jkteater