1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
public class TestSWT {
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
shell.setLayout(gridLayout);
Button butt1 = new Button(shell, SWT.PUSH);
Button butt2 = new Button(shell, SWT.PUSH);
Button butt3 = new Button(shell, SWT.PUSH);
Button butt4 = new Button(shell, SWT.PUSH);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.widthHint = 40;
gridData.grabExcessHorizontalSpace = false;
butt1.setLayoutData(gridData);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
butt2.setLayoutData(gridData);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.verticalAlignment = gridData.FILL_VERTICAL;
gridData.horizontalSpan = 2;
butt3.setLayoutData(gridData);
gridData = new GridData(GridData.FILL_BOTH);
gridData.widthHint = 40;
gridData.grabExcessHorizontalSpace = false;
butt4.setLayoutData(gridData);
shell.pack ();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
} |
Partager