diff options
author | Felipe Heidrich <fheidric> | 2011-02-17 16:51:26 +0000 |
---|---|---|
committer | Felipe Heidrich <fheidric> | 2011-02-17 16:51:26 +0000 |
commit | bdf4f9615d196b856239c88f144a55022b23fb8b (patch) | |
tree | 0e5e27480cf2d6fc747efe6640cc5536a0977577 | |
parent | 21a85b41f5c1c26f952db6e604e4efdfcf4f2b15 (diff) | |
download | eclipse.platform.swt-bdf4f9615d196b856239c88f144a55022b23fb8b.tar.gz eclipse.platform.swt-bdf4f9615d196b856239c88f144a55022b23fb8b.tar.xz eclipse.platform.swt-bdf4f9615d196b856239c88f144a55022b23fb8b.zip |
Bug 334147 - Several SWT snippets use incorrect positioning
7 files changed, 20 insertions, 7 deletions
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet225.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet225.java index e77752c314..7289c02b65 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet225.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet225.java @@ -48,6 +48,8 @@ public static void main(String[] args) { tip.setVisible(true); } }); + Rectangle clientArea = shell.getClientArea(); + button.setLocation(clientArea.x, clientArea.y); button.pack(); shell.setBounds(50, 50, 300, 200); shell.open(); diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet238.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet238.java index ca6ce04d49..c330fa3fa0 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet238.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet238.java @@ -17,6 +17,7 @@ package org.eclipse.swt.snippets; * http://www.eclipse.org/swt/snippets/ */ import org.eclipse.swt.*; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.*; public class Snippet238 { @@ -25,7 +26,8 @@ public static void main(String[] args) { Display display = new Display (); Shell shell = new Shell (display); Composite composite = new Composite (shell, SWT.BORDER); - composite.setSize (100, 100); + Rectangle clientArea = shell.getClientArea(); + composite.setBounds (clientArea.x, clientArea.y, 100, 100); Menu menu = new Menu (shell, SWT.POP_UP); MenuItem item1 = new MenuItem (menu, SWT.PUSH); item1.setText ("Push Item"); diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet241.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet241.java index 1026273060..2d34c0a2bd 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet241.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet241.java @@ -19,6 +19,7 @@ package org.eclipse.swt.snippets; import org.eclipse.swt.*; import org.eclipse.swt.events.*; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.*; public class Snippet241 { @@ -28,7 +29,8 @@ public static void main(String [] args) { Shell shell = new Shell(display); shell.setBounds(10,10,200,200); Text text1 = new Text(shell, SWT.MULTI | SWT.WRAP); - text1.setBounds(10,10,150,50); + Rectangle clientArea = shell.getClientArea(); + text1.setBounds(clientArea.x+10,clientArea.y+10,150,50); text1.setText("Tab will traverse out from here."); text1.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet245.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet245.java index 00b842515a..67c2739ac8 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet245.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet245.java @@ -32,7 +32,8 @@ public static void main(String [] args) { event.gc.drawOval(0, 0, rect.width - 1, rect.height - 1); } }); - shell.setBounds(10, 10, 200, 200); + Rectangle clientArea = shell.getClientArea(); + shell.setBounds(clientArea.x + 10, clientArea.y + 10, 200, 200); shell.open (); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet249.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet249.java index 6f24ab905f..204820d3c8 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet249.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet249.java @@ -18,6 +18,7 @@ package org.eclipse.swt.snippets; */ import org.eclipse.swt.*; import org.eclipse.swt.custom.*; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; @@ -28,10 +29,11 @@ public class Snippet249 { public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); - shell.setBounds (10, 10, 300, 200); + Rectangle clientArea = shell.getClientArea(); + shell.setBounds (clientArea.x + 10, clientArea.y + 10, 300, 200); // create the composite that the pages will share final Composite contentPanel = new Composite (shell, SWT.BORDER); - contentPanel.setBounds (100, 10, 190, 90); + contentPanel.setBounds (clientArea.x + 100, clientArea.y + 10, 190, 90); final StackLayout layout = new StackLayout (); contentPanel.setLayout (layout); @@ -52,7 +54,7 @@ public static void main (String [] args) { // create the button that will switch between the pages Button pageButton = new Button (shell, SWT.PUSH); pageButton.setText ("Push"); - pageButton.setBounds (10, 10, 80, 25); + pageButton.setBounds (clientArea.x + 10, clientArea.y + 10, 80, 25); pageButton.addListener (SWT.Selection, new Listener () { public void handleEvent (Event event) { pageNum = ++pageNum % 2; diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet274.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet274.java index f84234d951..7246a5396a 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet274.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet274.java @@ -19,6 +19,7 @@ package org.eclipse.swt.snippets; * @since 3.3 */ import org.eclipse.swt.*; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.*; public class Snippet274 { @@ -79,7 +80,8 @@ public class Snippet274 { } } } - tree.setSize(200, 200); + Rectangle clientArea = shell.getClientArea(); + tree.setBounds(clientArea.x, clientArea.y, 200, 200); shell.pack(); shell.open(); while (!shell.isDisposed()) { diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet276.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet276.java index ab779f6f42..2ae5afb42e 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet276.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet276.java @@ -36,6 +36,8 @@ public static void main (String[] args) { }; shell.addListener (SWT.MouseDown, listener); label.addListener (SWT.MouseDown, listener); + Rectangle clientArea = shell.getClientArea(); + label.setLocation(clientArea.x, clientArea.y); label.pack (); shell.open (); while (!shell.isDisposed ()){ |