16
16
* For a list of all SWT example snippets see
17
17
* http://www.eclipse.org/swt/snippets/
18
18
*/
19
- import java .util .Date ;
20
19
import org .eclipse .swt .*;
21
20
import org .eclipse .swt .widgets .*;
22
- import org .eclipse .swt .events .MouseEvent ;
23
- import org .eclipse .swt .events .MouseMoveListener ;
24
21
import org .eclipse .swt .events .SelectionAdapter ;
25
22
import org .eclipse .swt .events .SelectionEvent ;
26
23
import org .eclipse .swt .graphics .Color ;
@@ -30,8 +27,9 @@ public class TestShell {
30
27
31
28
public static void main (String [] args ) {
32
29
Display display = new Display ();
33
- final Shell shell = new Shell (display , /*SWT.BORDER | SWT.TITLE | SWT.MAX | */ SWT .RESIZE /*| SWT.MIN | SWT.CLOSE*/ );
34
- shell .setText ("hi" );
30
+ //final Shell shell = new Shell (display, /*SWT.BORDER | SWT.TITLE | SWT.MAX | */SWT.RESIZE /*| SWT.MIN | SWT.CLOSE*/);
31
+ final Shell shell = new Shell (display );
32
+ shell .setText ("hixxxxx" );
35
33
int style = shell .getStyle ();
36
34
int w = 0 ;
37
35
int h = 0 ;
@@ -43,124 +41,57 @@ public static void main (String [] args) {
43
41
System .out .println (h );
44
42
shell .setBackground (new Color (display , 255 , 0 , 0 ));
45
43
shell .setLayout (new GridLayout (3 , false ));
46
- // final Composite c0 = new Composite(shell, SWT.NONE);
47
- // final Composite c1 = new Composite(shell, SWT.BORDER);
48
- // final Composite c2 = new Composite(shell, SWT.BORDER);
49
- // c2.setLayout(new GridLayout());
50
- // c2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
51
- // final Composite c4 = new Composite(shell, SWT.BORDER);
52
- // c4.setLayout(new GridLayout(2, true));
53
- // c4.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
54
- //
55
- // final Composite c5 = new Composite(c4, SWT.BORDER);
56
- // c5.setLayout(new GridLayout());
57
- // c5.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
58
- //
59
- // final Composite c6 = new Composite(c4, SWT.BORDER);
60
- // c6.setLayout(new GridLayout());
61
- // final Button r1 = new Button(c6, SWT.RADIO);
62
- // r1.setText("Hi");
63
- // final Button r2 = new Button(c6, SWT.RADIO);
64
- // r2.setText("Hello");
65
- // final Button r3 = new Button(c6, SWT.PUSH);
66
- // r3.setText("World");
67
- // final Label l1 = new Label(c6, SWT.NONE);
68
- // l1.setText("World");
69
- // final Label l2 = new Label(c6, SWT.BORDER);
70
- // l2.setText("Great");
71
- //
72
- // c5.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
73
- //
74
- // final Composite c3 = new Composite(shell, SWT.BORDER);
75
- // c3.setLayout(new GridLayout());
76
- // c3.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
77
- // final Button btn = new Button(c3, SWT.PUSH);
78
- // btn.setText("Hello");
79
44
shell .setLocation (0 , 0 );
80
- // new Button(shell, SWT.PUSH).addSelectionListener(new SelectionAdapter() {
81
- // public void widgetSelected(SelectionEvent e) {
82
- // }
83
- // });
84
- // new Button(shell, SWT.PUSH).addSelectionListener(new SelectionAdapter() {
85
- // public void widgetSelected(SelectionEvent e) {
86
- // }
87
- // });
88
- // new Button(shell, SWT.PUSH).addSelectionListener(new SelectionAdapter() {
89
- // public void widgetSelected(SelectionEvent e) {
90
- // }
91
- // });
92
- // Button button = new Button(shell, SWT.CHECK);
93
- // Text text = new Text(shell, SWT.CHECK);
94
- // button.setText("Test");
95
- /*
96
- Label label = new Label(shell, SWT.NONE);
97
- label.setText("Hello J2S");
98
- label.addMouseMoveListener(new MouseMoveListener() {
99
- public void mouseMove(MouseEvent e) {
100
- // TODO Auto-generated method stub
45
+ final Link link1 = new Link (shell , SWT .NONE );
46
+ link1 .setText ("Hello J2S" );
47
+ System .out .println (".fdsasd." );
48
+ link1 .setSize (150 , 24 );
49
+ final Link link2 = new Link (shell , SWT .NONE );
50
+ link2 .setText ("Hello <a href=\" #\" >J2S</a>" );
51
+ link2 .setSize (150 , 24 );
52
+ link2 .addSelectionListener (new SelectionAdapter () {
53
+
54
+ public void widgetSelected (SelectionEvent e ) {
55
+ System .out .println (link1 .getSize ());
56
+ System .out .println (link2 .getSize ());
57
+
58
+ Shell dialog = new Shell (shell , SWT .DIALOG_TRIM | SWT .RESIZE );
59
+ dialog .setLayout (new GridLayout ());
60
+ dialog .setMinimumSize (503 , 332 );
61
+
62
+ System .out .println (dialog .getClientArea ());
63
+ System .out .println (dialog .getSize ());
64
+ System .out .println (dialog .computeSize (SWT .DEFAULT , SWT .DEFAULT , true ));
65
+ dialog .open ();
66
+ System .out .println (dialog .getClientArea ());
67
+ System .out .println (dialog .getSize ());
68
+ System .out .println (dialog .computeSize (SWT .DEFAULT , SWT .DEFAULT , true ));
69
+ dialog .pack ();
70
+ System .out .println (dialog .getClientArea ());
71
+ System .out .println (dialog .getSize ());
72
+ System .out .println (dialog .computeSize (SWT .DEFAULT , SWT .DEFAULT , true ));
101
73
}
74
+
102
75
});
103
- new Label(shell, SWT.NONE).setText("Hello J2S");
104
- new Label(shell, SWT.NONE).setText("Hello J2S");
105
- new Label(shell, SWT.NONE).setText("Hello J2S");
106
- new Link(shell, SWT.NONE).setText("Hello J2S");
107
- */
108
- new Link (shell , SWT .NONE ).setText ("Hello J2S" );
109
- new Link (shell , SWT .NONE ).setText ("Hello J2S" );
110
76
new Group (shell , SWT .NONE ).setText ("Hello J2S" );
111
77
new Composite (shell , SWT .BORDER );
112
- // button.addSelectionListener(new SelectionAdapter() {
113
- // public void widgetSelected(SelectionEvent e) {
114
- // System.out.println("************");
115
- //// print(c0);
116
- //// print(c1);
117
- //// print(c2);
118
- //// print(c3);
119
- //// print(btn);
120
- //// print(c4);
121
- //// print(c5);
122
- //// print(c6);
123
- //// print(r1);
124
- //// print(r2);
125
- //// print(r3);
126
- //// print(l1);
127
- //// print(l2);
128
- // print(shell);
129
- // }
130
- // });
131
78
System .out .println (shell .getClientArea ());
132
79
System .out .println (shell .getSize ());
133
80
// shell.pack();
134
81
shell .setSize (210 , 120 );
135
82
System .out .println (shell .getClientArea ());
136
83
System .out .println (shell .getSize ());
137
84
shell .open ();
85
+ System .out .println (shell .getClientArea ());
86
+ System .out .println (shell .getSize ());
87
+ shell .pack ();
88
+ System .out .println (shell .getClientArea ());
138
89
System .out .println (shell .getSize ());
90
+ System .out .println ();
139
91
while (!shell .isDisposed ()) {
140
92
if (!display .readAndDispatch ()) display .sleep ();
141
93
}
142
94
display .dispose ();
143
95
}
144
- public static void print (Button btn ) {
145
- // System.out.println(btn.getSize());
146
- System .out .println (btn .getBounds ());
147
- System .out .println (btn .getBorderWidth ());
148
- // System.out.println(btn.getLocation());
149
- System .out .println ("..======.." );
150
- }
151
- public static void print (Label btn ) {
152
- // System.out.println(btn.getSize());
153
- System .out .println (btn .getBounds ());
154
- System .out .println (btn .getBorderWidth ());
155
- // System.out.println(btn.getLocation());
156
- System .out .println ("..======.." );
157
- }
158
- public static void print (Composite c ) {
159
- // System.out.println(c.getSize());
160
- System .out .println (c .getBounds ());
161
- System .out .println (c .getBorderWidth ());
162
- System .out .println (c .getClientArea ());
163
- System .out .println ("..======.." );
164
- }
165
96
166
97
}
0 commit comments