Skip to content

Commit a6c0176

Browse files
committed
GridLayoutSWT adjusted
1 parent 0f488f6 commit a6c0176

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

com.example.swt.widgets/src/com/example/swt/widgets/GridLayoutSWT.java renamed to com.example.swt.widgets/src/com/example/swt/widgets/layouts/GridLayoutSWT.java

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.example.swt.widgets;
1+
package com.example.swt.widgets.layouts;
22

33
import org.eclipse.swt.SWT;
44
import org.eclipse.swt.layout.GridData;
@@ -17,41 +17,43 @@ public class GridLayoutSWT {
1717
public static void main(String[] args) {
1818
Display display = new Display();
1919
Shell shell = new Shell(display);
20-
// Create a new Gridlayout with 2 columns where the 2 column do no need
21-
// to be same size
20+
21+
// create a new GridLayout with two columns
22+
// of different size
2223
GridLayout layout = new GridLayout(2, false);
23-
// set the layout of the shell
24+
25+
// set the layout to the shell
2426
shell.setLayout(layout);
27+
2528
// Create a label and a button
2629
Label label = new Label(shell, SWT.NONE);
27-
label.setText("A lable");
30+
label.setText("A label");
2831
Button button = new Button(shell, SWT.PUSH);
2932
button.setText("Press Me");
3033

31-
// Create a new label that will spam two columns
34+
// Create a new label that will span two columns
3235
label = new Label(shell, SWT.BORDER);
3336
label.setText("This is a label");
3437
// Create new layout data
35-
GridData data = new GridData(SWT.FILL, SWT.LEFT, true,
36-
false, 2, 1);
38+
GridData data = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
3739
label.setLayoutData(data);
3840

3941
// Create a new label which is used as a separator
4042
label = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
43+
4144
// Create new layout data
42-
data = new GridData(SWT.FILL, SWT.LEFT, true, false, 2,
43-
1);
45+
data = new GridData(SWT.FILL, SWT.TOP, true, false);
4446
data.horizontalSpan = 2;
4547
label.setLayoutData(data);
4648

4749
// Create a right aligned button
4850
Button b = new Button(shell, SWT.PUSH);
4951
b.setText("New Button");
5052

51-
data = new GridData(SWT.BOTTOM, SWT.LEFT, false, false, 2,
52-
1);
53+
data = new GridData(SWT.BOTTOM, SWT.TOP, false, false, 2, 1);
5354
b.setLayoutData(data);
54-
55+
56+
// create a spinner with min value 0 and max value 1000
5557
Spinner spinner = new Spinner(shell, SWT.READ_ONLY);
5658
spinner.setMinimum(0);
5759
spinner.setMaximum(1000);
@@ -70,29 +72,29 @@ public static void main(String[] args) {
7072
composite.setLayoutData(gridData);
7173
composite.setLayout(new GridLayout(1, false));
7274

73-
Text text = new Text(composite, SWT.NONE);
74-
text.setText("Testing");
75+
Text txtTest = new Text(composite, SWT.NONE);
76+
txtTest.setText("Testing");
7577
gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
76-
text.setLayoutData(gridData);
78+
txtTest.setLayoutData(gridData);
7779

78-
text = new Text(composite, SWT.NONE);
79-
text.setText("Another test");
80-
// gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
81-
// text.setLayoutData(gridData);
80+
Text txtMoreTests = new Text(composite, SWT.NONE);
81+
txtMoreTests.setText("Another test");
82+
8283
Group group = new Group(shell, SWT.NONE);
8384
group.setText("This is my group");
8485
gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
8586
gridData.horizontalSpan = 2;
8687
group.setLayoutData(gridData);
8788
group.setLayout(new RowLayout(SWT.VERTICAL));
88-
text = new Text(group, SWT.NONE);
89-
text.setText("Another test");
89+
Text txtAnotherTest = new Text(group, SWT.NONE);
90+
txtAnotherTest.setText("Another test");
9091

9192
shell.pack();
9293
shell.open();
9394
while (!shell.isDisposed()) {
94-
if (!display.readAndDispatch())
95+
if (!display.readAndDispatch()) {
9596
display.sleep();
97+
}
9698
}
9799
display.dispose();
98100
}

0 commit comments

Comments
 (0)