1616 * For a list of all SWT example snippets see
1717 * http://www.eclipse.org/swt/snippets/
1818 */
19- import java .util .Date ;
2019import org .eclipse .swt .*;
2120import org .eclipse .swt .widgets .*;
22- import org .eclipse .swt .events .MouseEvent ;
23- import org .eclipse .swt .events .MouseMoveListener ;
2421import org .eclipse .swt .events .SelectionAdapter ;
2522import org .eclipse .swt .events .SelectionEvent ;
2623import org .eclipse .swt .graphics .Color ;
@@ -30,8 +27,9 @@ public class TestShell {
3027
3128public static void main (String [] args ) {
3229 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" );
3533 int style = shell .getStyle ();
3634 int w = 0 ;
3735 int h = 0 ;
@@ -43,124 +41,57 @@ public static void main (String [] args) {
4341 System .out .println (h );
4442 shell .setBackground (new Color (display , 255 , 0 , 0 ));
4543 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");
7944 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 ));
10173 }
74+
10275 });
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" );
11076 new Group (shell , SWT .NONE ).setText ("Hello J2S" );
11177 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- // });
13178 System .out .println (shell .getClientArea ());
13279 System .out .println (shell .getSize ());
13380// shell.pack();
13481 shell .setSize (210 , 120 );
13582 System .out .println (shell .getClientArea ());
13683 System .out .println (shell .getSize ());
13784 shell .open ();
85+ System .out .println (shell .getClientArea ());
86+ System .out .println (shell .getSize ());
87+ shell .pack ();
88+ System .out .println (shell .getClientArea ());
13889 System .out .println (shell .getSize ());
90+ System .out .println ();
13991 while (!shell .isDisposed ()) {
14092 if (!display .readAndDispatch ()) display .sleep ();
14193 }
14294 display .dispose ();
14395}
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- }
16596
16697}
0 commit comments