List of usage examples for org.eclipse.swt.widgets Button setBounds
public void setBounds(Rectangle bounds)
From source file:NoLayoutSimple.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Button button = new Button(shell, SWT.PUSH); button.setText("No layout"); button.setBounds(new Rectangle(5, 5, 100, 100)); shell.pack();//w ww.j a v a2 s . c o m shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:SyncExecExample.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); final Runnable print = new Runnable() { public void run() { System.out.println("Print from thread: \t" + Thread.currentThread().getName()); }//w ww . j ava2 s . com }; final Thread applicationThread = new Thread("applicationThread") { public void run() { System.out.println("Hello from thread: \t" + Thread.currentThread().getName()); display.syncExec(print); System.out.println("Bye from thread: \t" + Thread.currentThread().getName()); } }; shell.setText("syncExec Example"); shell.setSize(300, 100); Button button = new Button(shell, SWT.CENTER); button.setText("Click to start"); button.setBounds(shell.getClientArea()); button.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { applicationThread.start(); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) {// If no more entries in event queue display.sleep(); } } display.dispose(); }