Grid Layout Complex : Layout « SWT JFace Eclipse « Java






Grid Layout Complex

Grid Layout Complex

//Send questions, comments, bug reports, etc. to the authors:

//Rob Warner (rwarner@interspatial.com)
//Robert Harris (rbrt_harris@yahoo.com)

import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.SWT;

public class GridLayoutComplex {
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    layout.makeColumnsEqualWidth = true;
    shell.setLayout(layout);

    // Create the big button in the upper left
    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = 200;
    Button one = new Button(shell, SWT.PUSH);
    one.setText("one");
    one.setLayoutData(data);

    // Create a composite to hold the three buttons in the upper right
    Composite composite = new Composite(shell, SWT.NONE);
    data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    composite.setLayoutData(data);
    layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginHeight = 15;
    composite.setLayout(layout);

    // Create button "two"
    data = new GridData(GridData.FILL_BOTH);
    Button two = new Button(composite, SWT.PUSH);
    two.setText("two");
    two.setLayoutData(data);

    // Create button "three"
    data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
    Button three = new Button(composite, SWT.PUSH);
    three.setText("three");
    three.setLayoutData(data);

    // Create button "four"
    data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    Button four = new Button(composite, SWT.PUSH);
    four.setText("four");
    four.setLayoutData(data);

    // Create the long button across the bottom
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.grabExcessHorizontalSpace = true;
    data.horizontalSpan = 3;
    data.heightHint = 150;
    Button five = new Button(shell, SWT.PUSH);
    five.setText("five");
    five.setLayoutData(data);

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }
}


           
       








Related examples in the same category

1.SWT Layout Example in OneSWT Layout Example in One
2.SWT GridLayout DemoSWT GridLayout Demo
3.SWT GridLayoutSWT GridLayout
4.Control Size LocationControl Size Location
5.SWT RowLayout SampleSWT RowLayout Sample
6.SWT FillLayout SampleSWT FillLayout Sample
7.SWT Form Layout SampleSWT Form Layout Sample
8.SWT GridLayout SampleSWT GridLayout Sample
9.GridLayout Sample Grab SpaceGridLayout Sample Grab Space
10.Grid Layout SpanGrid Layout Span
11.Layout ComponentsLayout Components
12.Layout TermsLayout Terms
13.StackLayout SampleStackLayout Sample
14.BorderLayout SampleBorderLayout Sample
15.FormLayoutsFormLayouts
16.FormLayout SimpleFormLayout Simple
17.A BorderLayoutA BorderLayout
18.FillLayout HorizontalFillLayout Horizontal
19.FillLayout VerticalFillLayout Vertical
20.FormLayout ComplexFormLayout Complex
21.FormLayout Form AttachmentFormLayout Form Attachment
22.FormLayoutFormLayout
23.GridLayout 2x2GridLayout 2x2
24.No LayoutNo Layout
25.Row Layout TestRow Layout Test
26.Stack Layout TestStack Layout Test
27.Row Layout HorizontalRow Layout Horizontal
28.FillLayout ExampleFillLayout Example
29.FormLayout ExampleFormLayout Example
30.GridLayout ExampleGridLayout Example
31.GridLayout Example 2GridLayout Example 2
32.Layout ExampleLayout Example
33.RowLayout ExampleRowLayout Example
34.SWT FillLayout
35.SWY Radial Layout
36.Use of Radial Layout
37.GridLayout with All Options
38.Simplest GridLayout
39.SWT GridLayout: GridSpan
40.SWT RowLayout
41.SWT FillLayout Composite
42.SWT GridLayout: align widgets in a vertical columnSWT GridLayout: align widgets in a vertical column
43.SWT GridLayout: align widgets in a horizontal rowSWT GridLayout: align widgets in a horizontal row
44.Exclude a widget from a GridLayoutExclude a widget from a GridLayout
45.Insert widgets into a grid layoutInsert widgets into a grid layout
46.Align widgets in a GridLayoutAlign widgets in a GridLayout
47.FormLayout: create a simple OK and CANCEL dialog using form layoutFormLayout: create a simple OK and CANCEL dialog using form layout
48.FormLayout: center a label and single line text using a form layoutFormLayout: center a label and single line text using a form layout
49.FormLayout: create a simple dialog using form layoutFormLayout: create a simple dialog using form layout