2013-12-11 51 views
0

我創建的應用程序有兩個部分:如何在SWT中拆分SASH?

 1. tree viewer 
     2. table viewer + messages 

它看起來像

    ------------------------------- 
       - tree -   table - 
       -   -     - 
       -   - -----------------    
       -   - messages    
       ------------------------------- 

我試圖從thaty建立腰帶將分裂樹面積和表+消息區域。 然後,我想將表區域拆分爲兩個區域表和消息。

當我嘗試執行表和消息的第二次拆分時,出現錯誤消息。

這是

SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL); 
    Composite treeComposite = new Composite(sashForm, SWT.BORDER); 
    Composite detailsCompositePart = new Composite(sashForm, SWT.BORDER); 

    GridLayout parentSideGridLayout = new GridLayout(); 
    parentSideGridLayout.numColumns = 1; 
    detailsCompositePart.setLayout(parentSideGridLayout); 

    sashForm.setWeights(new int[] { 300, 700 }); 
    createTreePart(treeComposite) 

    SashForm verticalForm = new SashForm(detailsCompositePart, SWT.VERTICAL); 
    verticalForm.setWeights(new int[] { 800, 200 }); 

    detailsComposite = new Composite(sashForm, SWT.BORDER); 
       createDeatilsPart(detailsComposite) 
    messageComposite = new Composite(sashForm, SWT.NONE); 
      createMessagePart(messageComposite) 

我得到錯誤信息這statment

 verticalForm.setWeights(new int[] { 800, 200 }); 

「參數無效」後,當我試圖做第二個詞shash 你能告訴我我該怎麼代碼解決這個問題?

回答

1

你會得到那個錯誤,因爲verticalForm沒有兩個孩子。您必須在兩個Composite的構造函數中替換sashFormverticalForm

SashForm verticalForm = new SashForm(detailsCompositePart, SWT.VERTICAL); 

detailsComposite = new Composite(verticalForm , SWT.BORDER); 
createDeatilsPart(detailsComposite); 
messageComposite = new Composite(verticalForm , SWT.NONE); 
createMessagePart(messageComposite); 

verticalForm.setWeights(new int[] { 800, 200 });