1 | /*
|
---|
2 | * SWT002.java
|
---|
3 | * It's just a bit enhanced o.e.swt.examples.helloworld.HelloWorld1.java
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (c) 2002, 2004 EclipseOS2 Team.
|
---|
8 | */
|
---|
9 |
|
---|
10 | /*
|
---|
11 | * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
|
---|
12 | * This file is made available under the terms of the Common Public License v1.0
|
---|
13 | * which accompanies this distribution, and is available at
|
---|
14 | * http://www.eclipse.org/legal/cpl-v10.html
|
---|
15 | */
|
---|
16 |
|
---|
17 | import java.io.PrintWriter;
|
---|
18 | import java.io.StringWriter;
|
---|
19 |
|
---|
20 | import org.eclipse.swt.*;
|
---|
21 | import org.eclipse.swt.widgets.*;
|
---|
22 | import org.eclipse.swt.events.*;
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * This example demonstrates the minimum amount of code required
|
---|
26 | * to open an SWT Shell and process the events.
|
---|
27 | */
|
---|
28 |
|
---|
29 | public class SWT002 extends TestCase {
|
---|
30 |
|
---|
31 | static {
|
---|
32 | STEP= "002";
|
---|
33 | TEST = null;
|
---|
34 | DESC = "Simple Shells";
|
---|
35 | }
|
---|
36 |
|
---|
37 | public static void main (String [] args) {
|
---|
38 | go (new SWT002());
|
---|
39 | }
|
---|
40 |
|
---|
41 | protected void exec() {
|
---|
42 | System.out.println( "OBJECTIVE: Slightly modified HelloWorld1" );
|
---|
43 | System.out.println( "-------------------------------------------\n" );
|
---|
44 |
|
---|
45 | Display display = new Display ();
|
---|
46 | Shell shell = new SWT002 ().open (display);
|
---|
47 | while (!shell.isDisposed ()) {
|
---|
48 | if (!display.readAndDispatch ()) display.sleep ();
|
---|
49 | }
|
---|
50 | display.dispose ();
|
---|
51 | }
|
---|
52 |
|
---|
53 | public Shell open (Display display) {
|
---|
54 |
|
---|
55 | DisposeListener dl = new DisposeListener() {
|
---|
56 | public void widgetDisposed( DisposeEvent e )
|
---|
57 | {
|
---|
58 | System.out.println ("DisposeListener.widgetDisposed():");
|
---|
59 | if( e.widget instanceof Control )
|
---|
60 | System.out.println(" hwnd = "+
|
---|
61 | Integer.toHexString (((Control)e.widget).handle));
|
---|
62 | if( e.widget instanceof Decorations )
|
---|
63 | System.out.println(" title = ["+
|
---|
64 | ((Decorations)e.widget).getText()+"]");
|
---|
65 | }
|
---|
66 | };
|
---|
67 |
|
---|
68 | Shell shell = new Shell (display);
|
---|
69 | shell.addDisposeListener(dl);
|
---|
70 | shell.setText ("SWT002: Top Shell");
|
---|
71 | shell.open ();
|
---|
72 |
|
---|
73 | Shell shell2 = new Shell (shell);
|
---|
74 | shell2.addDisposeListener(dl);
|
---|
75 | shell2.setText ("SWT002: Secondary Shell");
|
---|
76 | shell2.open ();
|
---|
77 |
|
---|
78 | return shell;
|
---|
79 | }
|
---|
80 | }
|
---|