Posted on 2006-03-08 17:17
fortune 閱讀(1161)
評(píng)論(0) 編輯 收藏 所屬分類:
我的學(xué)習(xí)筆記
下圖是SWT中的一些術(shù)語(yǔ)說(shuō)明

SWT共有4種Layout:FillLayout,RowLayout,GridLayout,F(xiàn)ormLayout
FillLayout
FillLayout是最簡(jiǎn)單的Layout,它將widgets放在單行或單列上,強(qiáng)制使它們具有相同的大小,也就是說(shuō)每個(gè)widget的高度和寬度都和其中最高或最寬的那個(gè)widget一樣
marginHeight (與上下邊框的距離),marginWidth (與左右邊框的距離)(since3.0)
spacing,指定widgets之間的間隔距離(since3.0)
public class Snippet172 {
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
FillLayout fillLayout = new FillLayout ();
fillLayout.type = SWT.VERTICAL;
fillLayout.marginHeight = 20;
fillLayout.marginWidth = 15;
fillLayout.spacing = 10;
shell.setLayout (fillLayout);
Button button0 = new Button (shell, SWT.PUSH);
button0.setText ("button0");
Button button1 = new Button (shell, SWT.PUSH);
button1.setText ("button1");
Button button2 = new Button (shell, SWT.PUSH);
button2.setText ("button2");
shell.pack ();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ())
display.sleep ();
}
display.dispose ();
}
}
參考:http://www.eclipse.org/articles/Understanding%20Layouts/Understanding%20Layouts.htm