View difference between Paste ID: xxtJd3RS and
SHOW:
|
|
- or go back to the newest paste.
1 | - | |
1 | + | import org.eclipse.swt.widgets.Display; |
2 | import org.eclipse.swt.widgets.Shell; | |
3 | ||
4 | public class TestShells { | |
5 | public static void main(String[] args) { | |
6 | Display display = new Display(); | |
7 | boolean condition1=false; | |
8 | boolean condition2=false; | |
9 | ||
10 | if(condition1) { | |
11 | new Shell1(); | |
12 | eventLoop(display); | |
13 | } | |
14 | ||
15 | if(condition2) { | |
16 | new Shell2(); | |
17 | eventLoop(display); | |
18 | } | |
19 | ||
20 | new Shell3(); | |
21 | eventLoop(display); | |
22 | ||
23 | display.dispose(); | |
24 | } | |
25 | ||
26 | /** | |
27 | * @param display | |
28 | */ | |
29 | private static void eventLoop(Display display) { | |
30 | while (display.getShells().length > 0) { | |
31 | if (!display.readAndDispatch()) { | |
32 | display.sleep(); | |
33 | } | |
34 | } | |
35 | } | |
36 | } | |
37 | ||
38 | class Shell1 { | |
39 | Shell1() { | |
40 | Display display = Display.getDefault(); | |
41 | Shell shell = new Shell(display); | |
42 | shell.setText("Shell 1"); | |
43 | shell.open(); | |
44 | } | |
45 | } | |
46 | ||
47 | class Shell2 { | |
48 | Shell2() { | |
49 | Display display = Display.getDefault(); | |
50 | Shell shell = new Shell(display); | |
51 | shell.setText("Shell 2"); | |
52 | shell.open(); | |
53 | } | |
54 | } | |
55 | ||
56 | class Shell3 { | |
57 | Shell3() { | |
58 | Display display = Display.getDefault(); | |
59 | Shell shell = new Shell(display); | |
60 | shell.setText("Shell 3"); | |
61 | shell.open(); | |
62 | } | |
63 | } |