diff options
Diffstat (limited to 'examples/org.eclipse.swt.snippets')
10 files changed, 28 insertions, 8 deletions
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet100.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet100.java index 2fff80ae56..63ce3d6737 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet100.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet100.java @@ -27,7 +27,8 @@ public static void main(String[] args) { Shell shell = new Shell(display); shell.setBounds(10, 10, 200, 200); Text text = new Text(shell, SWT.MULTI); - text.setBounds(10, 10, 150, 150); + Rectangle clientArea = shell.getClientArea(); + text.setBounds(clientArea.x + 10, clientArea.y + 10, 150, 150); Font initialFont = text.getFont(); FontData[] fontData = initialFont.getFontData(); for (int i = 0; i < fontData.length; i++) { diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet101.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet101.java index d70e976232..1292066e61 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet101.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet101.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 Snippet101 { @@ -25,7 +26,8 @@ public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); Table table = new Table (shell, SWT.BORDER | SWT.MULTI); - table.setSize (200, 200); + Rectangle clientArea = shell.getClientArea (); + table.setBounds (clientArea.x, clientArea.y, 200, 200); for (int i=0; i<12; i++) { TableItem item = new TableItem (table, SWT.NONE); item.setText ("Item " + i); diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet102.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet102.java index 23056b65ce..38df07efe8 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet102.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet102.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 Snippet102 { @@ -25,7 +26,8 @@ public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (display); Tree tree = new Tree (shell, SWT.BORDER | SWT.MULTI); - tree.setSize (200, 200); + Rectangle clientArea = shell.getClientArea (); + tree.setBounds (clientArea.x, clientArea.y, 200, 200); for (int i=0; i<12; i++) { TreeItem item = new TreeItem (tree, SWT.NONE); item.setText ("Item " + i); diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet103.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet103.java index 5ab73fb70a..c8fa8c3391 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet103.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet103.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 Snippet103 { @@ -27,7 +28,8 @@ public static void main(String[] args) { Shell shell = new Shell(display); shell.setBounds(10, 10, 200, 240); Table table = new Table(shell, SWT.NONE); - table.setBounds(10, 10, 160, 160); + Rectangle clientArea = shell.getClientArea (); + table.setBounds (clientArea.x + 10, clientArea.y + 10, 160, 160); final TableItem[] items = new TableItem[4]; for (int i = 0; i < 4; i++) { diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet110.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet110.java index 5bda0c3796..084d03232d 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet110.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet110.java @@ -42,6 +42,8 @@ public static void main (String [] args) { for (int i=0; i < columnCount; i++) { table.getColumn (i).pack (); } + Rectangle clientArea = shell.getClientArea (); + table.setLocation (clientArea.x, clientArea.y); Point size = table.computeSize (SWT.DEFAULT, 200); table.setSize (size); shell.pack (); diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet113.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet113.java index 87ba34e384..bf432336b1 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet113.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet113.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 Snippet113 { @@ -29,7 +30,8 @@ public static void main (String [] args) { TableItem item = new TableItem (table, SWT.NONE); item.setText ("Item " + i); } - table.setSize (100, 100); + Rectangle clientArea = shell.getClientArea (); + table.setBounds (clientArea.x, clientArea.y, 100, 100); table.addListener (SWT.Selection, new Listener () { public void handleEvent (Event event) { String string = event.detail == SWT.CHECK ? "Checked" : "Selected"; diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet114.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet114.java index cec6fc63dd..b0c1f79d51 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet114.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet114.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 Snippet114 { @@ -29,7 +30,8 @@ public static void main (String [] args) { TreeItem item = new TreeItem (tree, SWT.NONE); item.setText ("Item " + i); } - tree.setSize (100, 100); + Rectangle clientArea = shell.getClientArea (); + tree.setBounds (clientArea.x, clientArea.y, 100, 100); tree.addListener (SWT.Selection, new Listener () { public void handleEvent (Event event) { String string = event.detail == SWT.CHECK ? "Checked" : "Selected"; diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet182.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet182.java index f710f219fb..32fe5f3d33 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet182.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet182.java @@ -19,6 +19,7 @@ package org.eclipse.swt.snippets; * @since 3.1 */ import org.eclipse.swt.*; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.*; public class Snippet182 { @@ -28,7 +29,8 @@ public class Snippet182 { Shell shell = new Shell(display); Link link = new Link(shell, SWT.BORDER); link.setText("This a very simple <A>link</A> widget."); - link.setSize(140, 40); + Rectangle clientArea = shell.getClientArea(); + link.setBounds(clientArea.x, clientArea.y, 140, 40); shell.pack (); shell.open(); while (!shell.isDisposed()) { diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet183.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet183.java index 88c5a1e8bd..03015505cb 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet183.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet183.java @@ -19,6 +19,7 @@ package org.eclipse.swt.snippets; * @since 3.1 */ import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.*; public class Snippet183 { @@ -29,7 +30,8 @@ public class Snippet183 { Link link = new Link(shell, SWT.NONE); String text = "The SWT component is designed to provide <a>efficient</a>, <a>portable</a> <a href=\"native\">access to the user-interface facilities of the operating systems</a> on which it is implemented."; link.setText(text); - link.setSize(400, 400); + Rectangle clientArea = shell.getClientArea(); + link.setBounds(clientArea.x, clientArea.y, 400, 400); link.addListener (SWT.Selection, new Listener () { public void handleEvent(Event event) { System.out.println("Selection: " + event.text); diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet184.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet184.java index 331895ae22..9f5ddfc168 100644 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet184.java +++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet184.java @@ -19,6 +19,7 @@ package org.eclipse.swt.snippets; * @since 3.1 */ import org.eclipse.swt.*; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.*; public class Snippet184 { @@ -32,6 +33,8 @@ public class Snippet184 { spinner.setSelection(500); spinner.setIncrement(1); spinner.setPageIncrement(100); + Rectangle clientArea = shell.getClientArea(); + spinner.setLocation(clientArea.x, clientArea.y); spinner.pack(); shell.pack(); shell.open(); |