Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet150.java')
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet150.java80
1 files changed, 40 insertions, 40 deletions
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet150.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet150.java
index ff5aec2417..c06f5eae8e 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet150.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet150.java
@@ -30,49 +30,49 @@ public class Snippet150 {
static int itemCount;
static CoolItem createItem(CoolBar coolBar, int count) {
- ToolBar toolBar = new ToolBar(coolBar, SWT.FLAT);
- for (int i = 0; i < count; i++) {
- ToolItem item = new ToolItem(toolBar, SWT.PUSH);
- item.setText(itemCount++ +"");
- }
- toolBar.pack();
- Point size = toolBar.getSize();
- CoolItem item = new CoolItem(coolBar, SWT.NONE);
- item.setControl(toolBar);
- Point preferred = item.computeSize(size.x, size.y);
- item.setPreferredSize(preferred);
- return item;
+ ToolBar toolBar = new ToolBar(coolBar, SWT.FLAT);
+ for (int i = 0; i < count; i++) {
+ ToolItem item = new ToolItem(toolBar, SWT.PUSH);
+ item.setText(itemCount++ +"");
+ }
+ toolBar.pack();
+ Point size = toolBar.getSize();
+ CoolItem item = new CoolItem(coolBar, SWT.NONE);
+ item.setControl(toolBar);
+ Point preferred = item.computeSize(size.x, size.y);
+ item.setPreferredSize(preferred);
+ return item;
}
public static void main(String[] args) {
- Display display = new Display();
- final Shell shell = new Shell(display);
+ Display display = new Display();
+ final Shell shell = new Shell(display);
shell.setText("Snippet 150");
- CoolBar coolBar = new CoolBar(shell, SWT.NONE);
- createItem(coolBar, 3);
- createItem(coolBar, 2);
- createItem(coolBar, 3);
- createItem(coolBar, 4);
- int style = SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL;
- Text text = new Text(shell, style);
- FormLayout layout = new FormLayout();
- shell.setLayout(layout);
- FormData coolData = new FormData();
- coolData.left = new FormAttachment(0);
- coolData.right = new FormAttachment(100);
- coolData.top = new FormAttachment(0);
- coolBar.setLayoutData(coolData);
- coolBar.addListener(SWT.Resize, event -> shell.layout());
- FormData textData = new FormData();
- textData.left = new FormAttachment(0);
- textData.right = new FormAttachment(100);
- textData.top = new FormAttachment(coolBar);
- textData.bottom = new FormAttachment(100);
- text.setLayoutData(textData);
- shell.open();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
- display.dispose();
+ CoolBar coolBar = new CoolBar(shell, SWT.NONE);
+ createItem(coolBar, 3);
+ createItem(coolBar, 2);
+ createItem(coolBar, 3);
+ createItem(coolBar, 4);
+ int style = SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL;
+ Text text = new Text(shell, style);
+ FormLayout layout = new FormLayout();
+ shell.setLayout(layout);
+ FormData coolData = new FormData();
+ coolData.left = new FormAttachment(0);
+ coolData.right = new FormAttachment(100);
+ coolData.top = new FormAttachment(0);
+ coolBar.setLayoutData(coolData);
+ coolBar.addListener(SWT.Resize, event -> shell.layout());
+ FormData textData = new FormData();
+ textData.left = new FormAttachment(0);
+ textData.right = new FormAttachment(100);
+ textData.top = new FormAttachment(coolBar);
+ textData.bottom = new FormAttachment(100);
+ text.setLayoutData(textData);
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) display.sleep();
+ }
+ display.dispose();
}
}

Back to the top