public class TestFillLayout { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display, SWT.DIALOG_TRIM); shell.setText("FillLayout演示"); shell.setSize(400, 300);
// 设置shell的布局 FillLayout layout = new FillLayout(); shell.setLayout(layout);
// 向shell添加控件 Button button1 = new Button(shell, SWT.PUSH); button1.setText("按钮1");
Button button2 = new Button(shell, SWT.PUSH); button2.setText("按钮2");
Button button3 = new Button(shell, SWT.PUSH); button3.setText("按钮3");
shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } } 界面如图1所示。
public class TestRowLayout { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display, SWT.DIALOG_TRIM); shell.setText("RowLayout演示"); shell.setSize(220, 200);