Mega Code Archive

 
Categories / Java Tutorial / SWT
 

Setting Widget bounds

import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class WidgetBoundsSetting {   public static void main(String[] args) {     Display display = new Display();     Shell shell = new Shell(display);     shell.setBounds(10, 10, 200, 200);     Button button1 = new Button(shell, SWT.PUSH);     button1.setText("&Typical button");     button1.setBounds(10, 10, 180, 30);     Button button2 = new Button(shell, SWT.PUSH);     button2.setText("&Overidden button");     button2.setBounds(10, 50, 180, 30);     shell.open();     while (!shell.isDisposed()) {       if (!display.readAndDispatch())         display.sleep();     }     display.dispose();   } }