Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti2009-05-01 15:50:45 +0000
committerSilenio Quarti2009-05-01 15:50:45 +0000
commit39899c993b293d90d475c954cd6b619be687e39a (patch)
tree9ee21841f17c5a990232534650a14ac2d7e5daf0 /examples
parent7cb5c786e16163f8c65186b604f1e0f5afa885ce (diff)
downloadeclipse.platform.swt-39899c993b293d90d475c954cd6b619be687e39a.tar.gz
eclipse.platform.swt-39899c993b293d90d475c954cd6b619be687e39a.tar.xz
eclipse.platform.swt-39899c993b293d90d475c954cd6b619be687e39a.zip
*** empty log message ***
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet43.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet43.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet43.java
index c8e63446a8..7b87042c19 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet43.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet43.java
@@ -25,11 +25,10 @@ public class Snippet43 {
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
- shell.open ();
Caret caret = new Caret (shell, SWT.NONE);
Color white = display.getSystemColor (SWT.COLOR_WHITE);
Color black = display.getSystemColor (SWT.COLOR_BLACK);
- Image image = new Image (display, 20, 20);
+ final Image image = new Image (display, 20, 20);
GC gc = new GC (image);
gc.setBackground (black);
gc.fillRectangle (0, 0, 20, 20);
@@ -39,12 +38,16 @@ public static void main (String [] args) {
gc.dispose ();
caret.setLocation (10, 10);
caret.setImage (image);
- gc = new GC (shell);
- gc.drawImage (image, 10, 64);
- caret.setVisible (false);
- gc.drawString ("Test", 12, 12);
caret.setVisible (true);
- gc.dispose ();
+ shell.addListener(SWT.Paint, new Listener() {
+ public void handleEvent(Event event) {
+ GC gc = event.gc;
+ gc.drawImage (image, 10, 64);
+ gc.drawString ("Test", 12, 12);
+ }
+ });
+ shell.open ();
+
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}

Back to the top