List of usage examples for org.eclipse.swt.widgets Button Button
public Button(Composite parent, int style)
From source file:EscapeMnemonicCharacter.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display, SWT.SHELL_TRIM); shell.setLayout(new RowLayout()); Button button = new Button(shell, SWT.RIGHT); button.setText("&&text on the button"); shell.open();/*from www .j a va 2 s . c o m*/ // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }
From source file:MainButton.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setText("Radio Buttons"); shell.pack();/* w w w . ja v a 2 s .c o m*/ Button[] radios = new Button[3]; radios[0] = new Button(shell, SWT.RADIO); radios[0].setSelection(true); radios[0].setText("Choice 1"); radios[0].setBounds(10, 5, 75, 30); radios[1] = new Button(shell, SWT.RADIO); radios[1].setText("Choice 2"); radios[1].setBounds(10, 30, 75, 30); radios[2] = new Button(shell, SWT.RADIO); radios[2].setText("Choice 3"); radios[2].setBounds(10, 55, 75, 30); shell.open(); shell.pack(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:CursorSetControl.java
public static void main(String[] args) { Display display = new Display(); Cursor cursor = new Cursor(display, SWT.CURSOR_HAND); Shell shell = new Shell(display); shell.open();//w ww .j ava 2s . c o m final Button b = new Button(shell, 0); b.setBounds(10, 10, 200, 200); b.setCursor(cursor); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } cursor.dispose(); display.dispose(); }
From source file:TabListFocusTransfer.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Button b1 = new Button(shell, SWT.PUSH); b1.setText("1"); Button b2 = new Button(shell, SWT.RADIO); b2.setText("2"); Button b3 = new Button(shell, SWT.RADIO); b3.setText("3"); Button b4 = new Button(shell, SWT.RADIO); b4.setText("4"); Button b5 = new Button(shell, SWT.PUSH); b5.setText("5"); Control[] tabList1 = new Control[] { b2, b1, b3, b5, b4 }; shell.setTabList(tabList1);/*from w w w . j av a 2s .c o m*/ shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:GridLayoutColumnNumber2.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 .ja v a2 s. co m 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"); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:RowLayoutHorizontal.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout(SWT.HORIZONTAL)); 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"); new Button(shell, SWT.PUSH).setText("seven"); shell.open();/* w w w. j a v a 2s .c om*/ 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); shell.setLayout(new GridLayout(3, true)); // Create three push buttons new Button(shell, SWT.PUSH).setText("Push 1"); new Button(shell, SWT.PUSH).setText("Push 2"); new Button(shell, SWT.PUSH).setText("Push 3"); // Create three checkboxes new Button(shell, SWT.CHECK).setText("Checkbox 1"); new Button(shell, SWT.CHECK).setText("Checkbox 2"); new Button(shell, SWT.CHECK).setText("Checkbox 3"); // Create three toggle buttons new Button(shell, SWT.TOGGLE).setText("Toggle 1"); new Button(shell, SWT.TOGGLE).setText("Toggle 2"); new Button(shell, SWT.TOGGLE).setText("Toggle 3"); // Create three radio buttons new Button(shell, SWT.RADIO).setText("Radio 1"); new Button(shell, SWT.RADIO).setText("Radio 2"); new Button(shell, SWT.RADIO).setText("Radio 3"); // Create three flat buttons new Button(shell, SWT.FLAT).setText("Flat 1"); new Button(shell, SWT.FLAT).setText("Flat 2"); new Button(shell, SWT.FLAT).setText("Flat 3"); // Create three arrow buttons new Button(shell, SWT.ARROW); new Button(shell, SWT.ARROW | SWT.LEFT); new Button(shell, SWT.ARROW | SWT.DOWN); shell.pack();//from ww w . j a v a2 s.co m 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); FormLayout layout = new FormLayout(); layout.marginHeight = 5;// w ww . j av a 2 s . c o m layout.marginWidth = 10; shell.setLayout(layout); new Button(shell, SWT.PUSH).setText("Button"); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:ControlSizeSetting.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setSize(150, 150);//from w ww. ja va 2s.c o m final Cursor[] cursor = new Cursor[1]; Button button = new Button(shell, SWT.PUSH); button.setText("Change cursor"); Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT); button.setSize(size); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } if (cursor[0] != null) cursor[0].dispose(); display.dispose(); }
From source file:ButtonSelection.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); for (int i = 0; i < 20; i++) { Button button = new Button(shell, SWT.TOGGLE); button.setText("B" + i); }// w ww . j a va2 s .co m Control[] children = shell.getChildren(); for (int i = 0; i < children.length; i++) { Control child = children[i]; ((Button) child).setSelection(true); } shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }