2014-10-30 108 views
0

我是SWT的新手,想用兩個垂直合成器(或類似的東西)製作應用程序。 在buttom複合材料保持簡單的表格。現在我需要一個可變高度的完整表格 - 用戶應該使用鼠標確定高度 - 就像調整eclipse視圖一樣。頂部的組合應調整空間。SWT:使用MouseListener調整表格(高度)

有點像SWT可能嗎?如果是的話,我會感謝每一個建議。

回答

2

您可以使用SashForm。用戶可調整大小。

Here就是一個例子。

public static void main(String[] args) 
{ 
    final Display display = new Display(); 
    final Shell shell = new Shell(display); 
    shell.setText("StackOverflow"); 
    shell.setLayout(new FillLayout()); 

    final SashForm sashForm = new SashForm(shell, SWT.HORIZONTAL); 

    Text text1 = new Text(sashForm, SWT.CENTER); 
    text1.setText("Text in pane #1"); 
    Text text2 = new Text(sashForm, SWT.CENTER); 
    text2.setText("Text in pane #2"); 

    final SashForm sashForm2 = new SashForm(sashForm, SWT.VERTICAL); 

    final Label labelA = new Label(sashForm2, SWT.BORDER | SWT.CENTER); 
    labelA.setText("Label in pane A"); 
    final Label labelB = new Label(sashForm2, SWT.BORDER | SWT.CENTER); 
    labelB.setText("Label in pane B"); 

    sashForm.setWeights(new int[] { 1, 2, 3 }); 

    new Label(shell, SWT.NONE).setText("Label"); 

    shell.pack(); 
    shell.setSize(400, 300); 
    shell.open(); 

    while (!shell.isDisposed()) 
    { 
     if (!display.readAndDispatch()) 
      display.sleep(); 
    } 
    display.dispose(); 
} 
+0

太好了。有用。謝謝 – MarryS 2014-10-30 12:53:54