List of usage examples for org.eclipse.swt.widgets Button Button
public Button(Composite parent, int style)
From source file:TabItemAddPushButton.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); final TabFolder tabFolder = new TabFolder(shell, SWT.BORDER | SWT.BOTTOM); for (int i = 0; i < 6; i++) { TabItem item = new TabItem(tabFolder, SWT.NONE); item.setText("TabItem " + i); Button button = new Button(tabFolder, SWT.PUSH); button.setText("Page " + i); item.setControl(button);/*ww w.j a v a2 s .c o m*/ } tabFolder.pack(); 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;/*ww w . ja va 2 s . co 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:SashFormSashWidth.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("SashForm Test"); // Fill the parent window with the buttons and sash shell.setLayout(new FillLayout()); // Create the SashForm and the buttons SashForm sashForm = new SashForm(shell, SWT.VERTICAL); new Button(sashForm, SWT.PUSH).setText("Left"); new Button(sashForm, SWT.PUSH).setText("Right"); sashForm.SASH_WIDTH = 20;// w w w . j av a2 s . c om shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:Snippet127.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Button button1 = new Button(shell, SWT.PUSH); button1.setBounds(10, 10, 80, 30);// w w w . j a v a 2 s . c o m button1.setText("no traverse"); button1.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { switch (e.detail) { case SWT.TRAVERSE_TAB_NEXT: case SWT.TRAVERSE_TAB_PREVIOUS: { e.doit = false; } } } }); Button button2 = new Button(shell, SWT.PUSH); button2.setBounds(100, 10, 80, 30); button2.setText("can traverse"); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:PopupListUsing.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setText("PopupList Test"); shell.setLayout(new RowLayout()); // Create a button to launch the list Button button = new Button(shell, SWT.PUSH); button.setText("Push Me"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { PopupList list = new PopupList(shell); list.setItems(new String[] { "A", "B", "C" }); String selected = list.open(shell.getBounds()); System.out.println(selected); }//from www .java 2 s . co m }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:GridLayoutSizeHint.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2;/*from w w w . j a v a 2 s . c om*/ gridLayout.makeColumnsEqualWidth = true; shell.setLayout(gridLayout); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); // Default alignment List list = new List(shell, SWT.BORDER); list.add("item 1"); list.add("item 2"); list.add("item 3"); GridData gridData = new GridData(); gridData.widthHint = 200; gridData.heightHint = 200; list.setLayoutData(gridData); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); Button button3 = new Button(shell, SWT.PUSH); button3.setText("3"); shell.setSize(450, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:RowLayoutMargin.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); rowLayout.marginLeft = 20;//from w w w.j av a2 s . com rowLayout.marginRight = 20; rowLayout.marginTop = 20; rowLayout.marginBottom = 20; shell.setLayout(rowLayout); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); List list = new List(shell, SWT.BORDER); list.add("item 1"); list.add("item 2"); list.add("item 3"); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); shell.setSize(450, 100); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:GridLayoutIndentation.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2;/*ww w . j a v a 2 s .co m*/ gridLayout.makeColumnsEqualWidth = true; shell.setLayout(gridLayout); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); // Default alignment List list = new List(shell, SWT.BORDER); list.add("item 1"); list.add("item 2"); list.add("item 3"); list.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER)); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); button2.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_END)); Button button3 = new Button(shell, SWT.PUSH); button3.setText("3"); GridData gridData = new GridData(GridData.VERTICAL_ALIGN_END); gridData.horizontalIndent = 50; button2.setLayoutData(gridData); shell.setSize(450, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:SashFromMaximizeControl.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("SashForm Test"); // Fill the parent window with the buttons and sash shell.setLayout(new FillLayout()); // Create the SashForm and the buttons SashForm sashForm = new SashForm(shell, SWT.VERTICAL); new Button(sashForm, SWT.PUSH).setText("Left"); Button control = new Button(sashForm, SWT.PUSH); control.setText("Right"); sashForm.setOrientation(SWT.HORIZONTAL); if (control == sashForm.getMaximizedControl()) { sashForm.setMaximizedControl(null); } else {// w ww . j a v a 2 s. c o m sashForm.setMaximizedControl(control); } shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:GridLayoutVerticalAlignment.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2;//w ww . ja v a 2 s. c o m gridLayout.makeColumnsEqualWidth = true; shell.setLayout(gridLayout); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); // Default alignment List list = new List(shell, SWT.BORDER); list.add("item 1"); list.add("item 2"); list.add("item 3"); list.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER)); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); button2.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_END)); Button button3 = new Button(shell, SWT.PUSH); button3.setText("3"); button3.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL)); shell.setSize(450, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }