GridLayout: makeColumnsEqualWidth : GridLayout « org.eclipse.swt.layout « Java by API






GridLayout: makeColumnsEqualWidth

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class MainClass {

  public static void main(String[] a) {
    Display display = new Display();
    Shell shell = new Shell(display);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    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();
  }
}


           
       








Related examples in the same category

1.new GridLayout()
2.FormLayout: marginHeight
3.FormLayout: marginWidth
4.GridLayout: numColumns