2013-10-10 32 views

回答

1

GridLayout實現這一目標最簡單的方法是插入虛擬Label s表示佔用的空間 「在前面」 你TreeViewer的:

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

    /* Top row */ 
    new Button(shell, SWT.PUSH).setText("Button"); 
    new Label(shell, SWT.NONE); 
    new Label(shell, SWT.NONE); 

    /* Middle row */ 
    new Label(shell, SWT.NONE); 
    new Button(shell, SWT.PUSH).setText("Button"); 
    new Label(shell, SWT.NONE); 

    /* Bottom row */ 
    new Label(shell, SWT.NONE); 
    new Label(shell, SWT.NONE); 
    new Button(shell, SWT.PUSH).setText("Button"); 

    shell.pack(); 
    shell.open(); 
    while (!shell.isDisposed()) 
    { 
     if (!display.readAndDispatch()) 
     { 
      display.sleep(); 
     } 
    } 
    display.dispose(); 
} 

產生以下:

enter image description here