Posted on 2006-03-08 17:17
fortune 阅读(1156)
评论(0) 编辑 收藏 所属分类:
我的学习笔记
下图是SWT中的一些术语说明
SWT共有4种Layout:FillLayout,RowLayout,GridLayout,FormLayout
FillLayout
FillLayout是最简单的Layout,它将widgets放在单行或单列上,强制使它们具有相同的大小,也就是说每个widget的高度和宽度都和其中最高或最宽的那个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