import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class GridData_GridLayoutTest2 { protected Shell shell; /** * Launch the application. * @param args */ public static void main(String[] args) { try { GridData_GridLayoutTest2 window = new GridData_GridLayoutTest2(); window.open(); } catch (Exception e) { e.printStackTrace(); } } /** * Open the window. */ public void open() { Display display = Display.getDefault(); createContents(); shell.open(); GridLayout layout = new GridLayout(); layout.numColumns = 3; shell.setLayout(layout); shell.layout(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } /** * Create contents of the window. */ protected void createContents() { shell = new Shell(); shell.setSize(450, 300); shell.setText("SWT Application"); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); GridData buttonGrid = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1); buttonGrid.heightHint = 100; buttonGrid.widthHint = 100; button1.setLayoutData(buttonGrid); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button2"); GridData button2data = new GridData(SWT.FILL,SWT.FILL,false,false,1,2); buttonGrid.heightHint = 100; buttonGrid.widthHint = 100; button2.setLayoutData(button2data); Button button3 = new Button(shell, SWT.PUSH); button3.setText("button3"); GridData button3data = new GridData(GridData.FILL_BOTH); button3.setLayoutData(button3data); Button button4 = new Button(shell, SWT.PUSH); button4.setText("button4"); GridData button4Grid = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1); button4Grid.heightHint = 100; button4Grid.widthHint = 100; button4.setLayoutData(button4Grid); } }
import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.S