Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2019-06-03 21:22:32 +0000
committerEric Williams2019-06-05 17:18:50 +0000
commit1b56697db0519a32d9694fb9747a0cd54f9f7041 (patch)
treee5b16ea54a86f9d4316fe4d4ff71baab160c93d5 /examples
parent9c2ad38d59e0a97007f356b38de17ea8524544e8 (diff)
downloadeclipse.platform.swt-1b56697db0519a32d9694fb9747a0cd54f9f7041.tar.gz
eclipse.platform.swt-1b56697db0519a32d9694fb9747a0cd54f9f7041.tar.xz
eclipse.platform.swt-1b56697db0519a32d9694fb9747a0cd54f9f7041.zip
Bug 547938 - [Snippets] Make Snippets reusable without class reload
Some Snippets initialize Display and/or Shell on class initialization. SnippetLauncher and especially SnippetExplorer may launch Snippets more than once without reinitializing the class. Therefore the Display and/or Shell is already disposed on the second launch. Change-Id: I662b27e656c2b439dd8f860dd04b370046f71a82 Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet18.java6
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet366.java6
2 files changed, 7 insertions, 5 deletions
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet18.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet18.java
index bee66965b8..3fb374f99d 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet18.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet18.java
@@ -20,13 +20,14 @@ 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.graphics.*;
import org.eclipse.swt.widgets.*;
public class Snippet18 {
public static void main (String [] args) {
- Shell shell = new Shell ();
+ Display display = new Display();
+ Shell shell = new Shell (display);
ToolBar bar = new ToolBar (shell, SWT.BORDER);
for (int i=0; i<8; i++) {
ToolItem item = new ToolItem (bar, SWT.PUSH);
@@ -36,7 +37,6 @@ public static void main (String [] args) {
bar.setLocation (clientArea.x, clientArea.y);
bar.pack ();
shell.open ();
- Display display = shell.getDisplay ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet366.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet366.java
index 6215bc0a17..0a9e98cc68 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet366.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet366.java
@@ -26,10 +26,12 @@ import org.eclipse.swt.widgets.*;
* http://www.eclipse.org/swt/snippets/
*/
public class Snippet366 {
- static Display display = new Display();
- static Shell shell = new Shell(display);
+ static Display display;
+ static Shell shell;
public static void main (String [] args) {
+ display = new Display();
+ shell = new Shell(display);
shell.setLayout (new RowLayout ());
makeArrowGroup ();

Back to the top