2010-04-06 3 views
1

세 부분으로 나뉘는 창을 만들려고합니다. 사이즈를 변경할 수없는 머리말과 꼬리말, 그리고 윈도우의 나머지 영역을 채우기 위해 펼쳐지는 내용 영역. 시작하려면, 나는 다음과 같은 클래스 생성 :JFace ApplicationWindow : createContents가 작동하지 않습니다.

public class MyWindow extends ApplicationWindow { 
    Color white; 
    Font mainFont; 
    Font headerFont; 

    public MyWindow() { 
     super(null); 
     } 

    protected Control createContents(Composite parent) { 
     Display currentDisplay = Display.getCurrent(); 
     white = new Color(currentDisplay, 255, 255, 255); 
     mainFont = new Font(currentDisplay, "Tahoma", 8, 0); 
     headerFont = new Font(currentDisplay, "Tahoma", 16, 0); 

     // Main layout Composites and overall FillLayout 
     Composite container = new Composite(parent, SWT.NO_RADIO_GROUP); 
     Composite header = new Composite(container, SWT.NO_RADIO_GROUP); 
     Composite mainContents = new Composite(container, SWT.NO_RADIO_GROUP);; 
     Composite footer = new Composite(container, SWT.NO_RADIO_GROUP);; 
     FillLayout containerLayout = new FillLayout(SWT.VERTICAL); 
     container.setLayout(containerLayout); 

     // Header 
     Label headerLabel = new Label(header, SWT.LEFT); 
     headerLabel.setText("Header"); 
     headerLabel.setFont(headerFont); 

     // Main contents 
     Label contentsLabel = new Label(mainContents, SWT.CENTER); 
     contentsLabel.setText("Main Content Here"); 
     contentsLabel.setFont(mainFont); 

     // Footer 
     Label footerLabel = new Label(footer, SWT.CENTER); 
     footerLabel.setText("Footer Here"); 
     footerLabel.setFont(mainFont); 

     return container; 
    } 

    public void dispose() { 
     cleanUp(); 
    } 

    @Override 
    protected void finalize() throws Throwable { 
     cleanUp(); 
     super.finalize(); 
    } 

    private void cleanUp() { 
     if (headerFont != null) { 
      headerFont.dispose(); 
     } 
     if (mainFont != null) { 
      mainFont.dispose(); 
     } 
     if (white != null) { 
      white.dispose(); 
     } 
    } 
} 

를 그리고 이렇게 그것을 실행할 때이 빈 창에 결과 : 내가 잘못 뭐하는 거지

public static void main(String[] args) { 
    MyWindow myWindow = new MyWindow(); 
    myWindow.setBlockOnOpen(true); 
    myWindow.open(); 
    Display.getCurrent().dispose(); 
} 

내가 세 가지를 참조하지 않는 것이 내가 그들을 표시하려고하는 방식으로 레이블을 붙였습니까? createContents 코드가 확실히 호출되고 있습니다. Eclipse에서 디버그 모드로 단계별로 수행 할 수 있습니다.

답변

0

외관상으로는 레이블의 크기와 위치를 설정하여 표시되도록해야했습니다.

관련 문제