Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2019-05-21 18:34:40 +0000
committerEric Williams2019-06-05 17:39:11 +0000
commit497b02a9d8d940b9bdd51289ed7cf5eba9c12615 (patch)
treea87afcf5c4eedc99ede2aa5b716c90922c29be1d
parent1b56697db0519a32d9694fb9747a0cd54f9f7041 (diff)
downloadeclipse.platform.swt-497b02a9d8d940b9bdd51289ed7cf5eba9c12615.tar.gz
eclipse.platform.swt-497b02a9d8d940b9bdd51289ed7cf5eba9c12615.tar.xz
eclipse.platform.swt-497b02a9d8d940b9bdd51289ed7cf5eba9c12615.zip
Bug 547938 - [Snippets] Snippet13: do paint in paint listener
The single paint operation after open is even for a Snippet to simple and a bad example. Furthermore the Snippet does not work on GTK at the moment. Change-Id: Ia77b52376e208db0865c7c4a3d97ac7c48c9eb88 Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet13.java27
1 files changed, 14 insertions, 13 deletions
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet13.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet13.java
index 9ce06368c4..25479e37cc 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet13.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet13.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -19,22 +19,23 @@ package org.eclipse.swt.snippets;
* For a list of all SWT example snippets see
* http://www.eclipse.org/swt/snippets/
*/
-import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
public class Snippet13 {
-public static void main (String [] args) {
- Display display = new Display ();
- Shell shell = new Shell (display);
- shell.open ();
- GC gc = new GC (shell);
- gc.setLineWidth (4);
- gc.drawRectangle (20, 20, 100, 100);
- gc.dispose ();
- while (!shell.isDisposed ()) {
- if (!display.readAndDispatch ()) display.sleep ();
+public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.addListener(SWT.Paint, e -> {
+ e.gc.setLineWidth(4);
+ e.gc.drawRectangle(20, 20, 100, 100);
+ });
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
}
- display.dispose ();
+ display.dispose();
}
}

Back to the top