2014-10-30 56 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