Source Code : GridLayout with All Options

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

GridLayout with All Options

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.Composite;

public class Ch6GridLayoutAllOptionsComposite extends Composite {

  public Ch6GridLayoutAllOptionsComposite(Composite parent) {
    super(parent, SWT.NONE);

    int[] fillStyles = { SWT.NONE, GridData.FILL_HORIZONTAL,
        GridData.FILL_VERTICAL, GridData.FILL_BOTH };

    int[] alignStyles = { SWT.NONE, GridData.HORIZONTAL_ALIGN_BEGINNING,
        GridData.HORIZONTAL_ALIGN_END,
        GridData.HORIZONTAL_ALIGN_CENTER,
        GridData.HORIZONTAL_ALIGN_FILL,
        GridData.VERTICAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_END,
        GridData.VERTICAL_ALIGN_CENTER, GridData.VERTICAL_ALIGN_FILL };

    GridLayout layout = new GridLayout(fillStyles.length, false);
    setLayout(layout);
    int count = 0;
    for (int i = 0; i < alignStyles.length; ++i) {
      for (int j = 0; j < fillStyles.length; ++j) {
        Button button = new Button(this, SWT.NONE);
        button.setText("Cell " + count++);
        button.setLayoutData(new GridData(fillStyles[j]
            | alignStyles[i]));
      }
    }
  }
}


           
       

Thank with us