Mega Code Archive

 
Categories / Java by API / Org Eclipse Swt Widgets
 

New Composite(Shell s, SWT NO_FOCUS)

import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class MainClass {   public static void main(String[] a) {     Display d = new Display();     Shell s = new Shell(d);     GridLayout gl = new GridLayout();     gl.numColumns=4;     s.setLayout(gl);     s.setSize(250,275);     s.setText("A Shell Composite Example");     s.setLayout(gl);     GridData gd = new GridData(GridData.FILL_BOTH);     gd.horizontalSpan = 4;     gd = new GridData();          Composite c1 = new Composite(s, SWT.NO_FOCUS);     gd = new GridData(GridData.FILL_HORIZONTAL);     c1.setLayoutData(gd);     Composite c2 = new Composite(s, SWT.NO_FOCUS);     gd = new GridData(GridData.FILL_HORIZONTAL);     c2.setLayoutData(gd);          Composite c = new Composite(s, SWT.NO_FOCUS);     c.setLayout(new RowLayout());     Button b1 = new Button(c, SWT.PUSH | SWT.BORDER);     b1.setText("OK");     Button b2 = new Button(c, SWT.PUSH | SWT.BORDER);     b2.setText("Cancel");     gd = new GridData(GridData.FILL_HORIZONTAL);     c.setLayoutData(gd);     s.open();     while (!s.isDisposed()) {       if (!d.readAndDispatch())         d.sleep();     }     d.dispose();   } }