List of usage examples for org.eclipse.swt.widgets Button setLayoutData
public void setLayoutData(Object layoutData)
From source file:RowLayoutTest.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); RowLayout layout = new RowLayout(SWT.VERTICAL); layout.marginLeft = 20;//from www . java 2 s.co m layout.marginTop = 20; layout.justify = true; shell.setLayout(layout); new Button(shell, SWT.PUSH).setText("one"); new Button(shell, SWT.PUSH).setText("two"); new Button(shell, SWT.PUSH).setText("three"); new Button(shell, SWT.PUSH).setText("four"); new Button(shell, SWT.PUSH).setText("five"); new Button(shell, SWT.PUSH).setText("six"); Button b = new Button(shell, SWT.PUSH); b.setText("seven"); b.setLayoutData(new RowData(100, 100)); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:RowLayoutTest.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); RowLayout layout = new RowLayout(SWT.VERTICAL); layout.marginLeft = 12;/*w ww . jav a2 s. c o m*/ layout.marginTop = 0; layout.justify = true; shell.setLayout(layout); new Button(shell, SWT.PUSH).setText("one"); new Button(shell, SWT.PUSH).setText("two"); new Button(shell, SWT.PUSH).setText("three"); new Button(shell, SWT.PUSH).setText("four"); new Button(shell, SWT.PUSH).setText("five"); new Button(shell, SWT.PUSH).setText("six"); Button b = new Button(shell, SWT.PUSH); b.setText("seven"); b.setLayoutData(new RowData(100, 100)); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:FormLayoutAttachControl.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FormLayout()); FormData formData = new FormData(); formData.left = new FormAttachment(50); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); button1.setLayoutData(formData); shell.setSize(450, 400);/*from w ww . j a va2s.c o m*/ shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:FormLayoutFormDataWidthHeight.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FormLayout()); FormData formData = new FormData(); formData.width = 100;/*from w w w . j a v a2s . c o m*/ formData.height = 200; Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); button1.setLayoutData(formData); shell.setSize(450, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:GridLayoutFillBoth.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); GridLayout layout = new GridLayout(); layout.numColumns = 3;// w w w . ja va 2 s . c o m layout.makeColumnsEqualWidth = true; shell.setLayout(layout); // Create the big button in the upper left GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = 200; Button one = new Button(shell, SWT.PUSH); one.setText("one"); one.setLayoutData(data); // Create a composite to hold the three buttons in the upper right Composite composite = new Composite(shell, SWT.NONE); // Create button "two" data = new GridData(GridData.FILL_BOTH); Button two = new Button(composite, SWT.PUSH); two.setText("two"); two.setLayoutData(data); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:GridLayoutHORIZONTALALIGNCENTER.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); GridLayout layout = new GridLayout(); layout.numColumns = 3;/*from w w w . j a v a 2 s . c om*/ layout.makeColumnsEqualWidth = true; shell.setLayout(layout); // Create the big button in the upper left GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = 200; Button one = new Button(shell, SWT.PUSH); one.setText("one"); one.setLayoutData(data); // Create a composite to hold the three buttons in the upper right Composite composite = new Composite(shell, SWT.NONE); // Create button "three" data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER); Button three = new Button(composite, SWT.PUSH); three.setText("three"); three.setLayoutData(data); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:GridLayoutComplex.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); GridLayout layout = new GridLayout(); layout.numColumns = 3;// ww w. j a v a 2 s . co m layout.makeColumnsEqualWidth = true; shell.setLayout(layout); // Create the big button in the upper left GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = 200; Button one = new Button(shell, SWT.PUSH); one.setText("one"); one.setLayoutData(data); // Create a composite to hold the three buttons in the upper right Composite composite = new Composite(shell, SWT.NONE); data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 2; composite.setLayoutData(data); layout = new GridLayout(); layout.numColumns = 1; layout.marginHeight = 15; composite.setLayout(layout); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:MainClass.java
public static void main(String[] a) { Display display = new Display(); Shell shell = new Shell(display); GridLayout layout = new GridLayout(); layout.numColumns = 2;/*ww w . ja v a2 s .c o m*/ layout.makeColumnsEqualWidth = true; shell.setLayout(layout); GridData data = new GridData(GridData.FILL_BOTH); Button one = new Button(shell, SWT.PUSH); one.setText("one"); one.setLayoutData(data); data = new GridData(GridData.FILL_BOTH); Button two = new Button(shell, SWT.PUSH); two.setText("two"); two.setLayoutData(data); data = new GridData(GridData.FILL_BOTH); Button three = new Button(shell, SWT.PUSH); three.setText("three"); three.setLayoutData(data); data = new GridData(GridData.FILL_BOTH); Button four = new Button(shell, SWT.PUSH); four.setText("four"); four.setLayoutData(data); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:GridLayout2x2.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); GridLayout layout = new GridLayout(); layout.numColumns = 2;//from w w w.j ava 2s. c om layout.makeColumnsEqualWidth = true; shell.setLayout(layout); GridData data = new GridData(GridData.FILL_BOTH); Button one = new Button(shell, SWT.PUSH); one.setText("one"); one.setLayoutData(data); data = new GridData(GridData.FILL_BOTH); Button two = new Button(shell, SWT.PUSH); two.setText("two"); two.setLayoutData(data); data = new GridData(GridData.FILL_BOTH); Button three = new Button(shell, SWT.PUSH); three.setText("three"); three.setLayoutData(data); data = new GridData(GridData.FILL_BOTH); Button four = new Button(shell, SWT.PUSH); four.setText("four"); four.setLayoutData(data); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet315.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 315"); shell.setLayout(new GridLayout()); final Button button = new Button(shell, SWT.CHECK); button.setLayoutData( new GridData(GridData.GRAB_VERTICAL | GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_CENTER)); button.setText("Tri-state"); /* Make the button toggle between three states */ button.addListener(SWT.Selection, e -> { if (button.getSelection()) { if (!button.getGrayed()) { button.setGrayed(true);/*from w w w . j a v a 2 s .c o m*/ } } else { if (button.getGrayed()) { button.setGrayed(false); button.setSelection(true); } } }); /* Read the tri-state button (application code) */ button.addListener(SWT.Selection, e -> { if (button.getGrayed()) { System.out.println("Grayed"); } else { if (button.getSelection()) { System.out.println("Selected"); } else { System.out.println("Not selected"); } } }); shell.setSize(300, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }