1 package org.simantics.databoard.forms;
\r
3 import org.eclipse.swt.SWT;
\r
4 import org.eclipse.swt.layout.GridData;
\r
5 import org.eclipse.swt.layout.GridLayout;
\r
6 import org.eclipse.swt.layout.RowLayout;
\r
7 import org.eclipse.swt.widgets.Button;
\r
8 import org.eclipse.swt.widgets.Composite;
\r
9 import org.eclipse.swt.widgets.Display;
\r
10 import org.eclipse.swt.widgets.Group;
\r
11 import org.eclipse.swt.widgets.Label;
\r
12 import org.eclipse.swt.widgets.Shell;
\r
13 import org.eclipse.swt.widgets.Spinner;
\r
14 import org.eclipse.swt.widgets.Text;
\r
16 public class LayoutSnippet {
\r
17 public static void main(String[] args) {
\r
18 Display display = new Display();
\r
19 Shell shell = new Shell(display);
\r
20 // set the layout of the shell
\r
21 shell.setLayout(new GridLayout(3, false));
\r
22 // Create a label and a button
\r
23 Label label = new Label(shell, SWT.NONE);
\r
24 label.setText("A label");
\r
25 Button button = new Button(shell, SWT.PUSH);
\r
26 button.setText("Press Me");
\r
28 // Create a new label that will spam two columns
\r
29 label = new Label(shell, SWT.BORDER);
\r
30 label.setText("This is a label");
\r
31 // Create new layout data
\r
32 label.setLayoutData(new GridData(GridData.FILL,
\r
33 GridData.BEGINNING, true, false, 2, 1));
\r
35 // Create a new label which is used as a separator
\r
36 label = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
\r
37 // Create new layout data
\r
38 label.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false, 2, 1));
\r
40 // Create a right aligned button
\r
41 Button b = new Button(shell, SWT.PUSH);
\r
42 b.setText("New Button");
\r
44 b.setLayoutData(new GridData(GridData.END, GridData.BEGINNING, false, false, 2, 1));
\r
46 Spinner spinner = new Spinner(shell, SWT.READ_ONLY);
\r
47 spinner.setMinimum(0);
\r
48 spinner.setMaximum(1000);
\r
49 spinner.setSelection(500);
\r
50 spinner.setIncrement(1);
\r
51 spinner.setPageIncrement(100);
\r
52 GridData gridData = new GridData(SWT.FILL,
\r
53 SWT.FILL, true, false);
\r
54 gridData.widthHint = SWT.DEFAULT;
\r
55 gridData.heightHint = SWT.DEFAULT;
\r
56 gridData.horizontalSpan=2;
\r
57 spinner.setLayoutData(gridData);
\r
59 Composite composite = new Composite(shell, SWT.BORDER);
\r
60 gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
\r
61 gridData.horizontalSpan= 2;
\r
62 composite.setLayoutData(gridData);
\r
63 composite.setLayout(new GridLayout(1, false));
\r
66 Text text = new Text(composite, SWT.NONE);
\r
67 text.setText("Testing");
\r
68 gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
\r
69 text.setLayoutData(gridData);
\r
71 text = new Text(composite, SWT.NONE);
\r
72 text.setText("Another test");
\r
73 // gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
\r
74 // text.setLayoutData(gridData);
\r
75 Group group = new Group(shell, SWT.NONE);
\r
76 group.setText("This is my group");
\r
77 gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
\r
78 gridData.horizontalSpan= 2;
\r
79 group.setLayoutData(gridData);
\r
80 group.setLayout(new RowLayout(SWT.VERTICAL));
\r
81 text = new Text(group, SWT.NONE);
\r
82 text.setText("Another test");
\r
87 while (!shell.isDisposed()) {
\r
88 if (!display.readAndDispatch())
\r