List of usage examples for org.eclipse.swt.widgets Button Button
public Button(Composite parent, int style)
From source file:EventSelection.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display, SWT.SHELL_TRIM); shell.setLayout(new FillLayout()); Button button = new Button(shell, SWT.RIGHT); button.setText("text on the button"); button.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent arg0) { System.out.println("selected"); }// w w w . j a v a2 s. com public void widgetDefaultSelected(SelectionEvent arg0) { } }); shell.open(); // 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:RowLayoutType.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); rowLayout.type = SWT.VERTICAL;/*from w ww .j a v a 2 s .co m*/ 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, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:RowLayoutRowData.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); shell.setLayout(rowLayout);/*from w w w.j a v a 2 s.co m*/ 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"); list.setLayoutData(new RowData(100, 35)); Button button2 = new Button(shell, SWT.PUSH); button2.setText("button #2"); shell.setSize(450, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:FormLayoutSimple.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); FormLayout layout = new FormLayout(); layout.marginHeight = 5;//from ww w. j a va 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:MainClass.java
public static void main(String[] a) { Display d = new Display(); Shell s = new Shell(d); s.setSize(250, 250);//from ww w. j a va 2s . co m s.setText("A RowLayout Example"); s.setLayout(new RowLayout()); final Text t = new Text(s, SWT.SINGLE | SWT.BORDER); final Button b = new Button(s, SWT.BORDER); final Button b1 = new Button(s, SWT.BORDER); b.setText("OK"); b1.setText("Cancel"); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } d.dispose(); }
From source file:AsyncExecDisplay.java
public static void main(String[] args) { Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final Button buttonAsyncExec = new Button(shell, SWT.PUSH); buttonAsyncExec.setText("start"); buttonAsyncExec.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { }/*w w w. j av a2 s . c o m*/ public void widgetSelected(SelectionEvent e) { buttonAsyncExec.setText("Calculation in progress ..."); getTask2(buttonAsyncExec).start(); } }); shell.open(); while (!shell.isDisposed()) { // Event loop. if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:FormLayoutAttachEachOther.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display, SWT.SHELL_TRIM); shell.setLayout(new FormLayout()); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); FormData formData = new FormData(); formData.left = new FormAttachment(20); formData.top = new FormAttachment(20); button1.setLayoutData(formData);//from ww w . j a va 2 s .c o m Button button2 = new Button(shell, SWT.PUSH); button2.setText("button number 2"); formData = new FormData(); formData.left = new FormAttachment(button1, 0, SWT.CENTER); formData.top = new FormAttachment(button1, 0, SWT.CENTER); button2.setLayoutData(formData); shell.pack(); shell.open(); // 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:RowLayoutFill.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); RowLayout rowLayout = new RowLayout(); rowLayout.fill = true; // Overriding default values. shell.setLayout(rowLayout);// w w w.j a v a 2 s.co m 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:FormLayoutControlOffsetAttachment.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FormLayout()); Button button1 = new Button(shell, SWT.PUSH); button1.setText("button1"); Point size = button1.computeSize(SWT.DEFAULT, SWT.DEFAULT); int offset = size.x / 2; FormData formData = new FormData(); formData.left = new FormAttachment(50, -1 * offset); button1.setLayoutData(formData);//w ww . ja v a 2s . c o m shell.setSize(450, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:EventTypeGet.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); Button button = new Button(shell, SWT.NONE); button.setText("Click and check the console"); button.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { System.out.println(getEventName(e.type)); switch (e.type) { case SWT.Selection: System.out.println("Button pressed"); break; }/*w w w.j a v a 2 s. c o m*/ } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }