Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2b56313

Browse files
author
zhourenjian
committed
Remove Java 5 syntaxes and update the tests
1 parent 0b2d516 commit 2b56313

File tree

2 files changed

+37
-113
lines changed

2 files changed

+37
-113
lines changed

tests/net.sf.j2s.test.swt/src/net/sf/j2s/test/swt/widgets/TestScrollBar.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@
33
import org.eclipse.swt.SWT;
44
import org.eclipse.swt.events.SelectionAdapter;
55
import org.eclipse.swt.events.SelectionEvent;
6-
import org.eclipse.swt.events.SelectionListener;
76
import org.eclipse.swt.layout.FillLayout;
87
import org.eclipse.swt.layout.GridData;
98
import org.eclipse.swt.layout.GridLayout;
109
import org.eclipse.swt.widgets.Button;
1110
import org.eclipse.swt.widgets.Composite;
1211
import org.eclipse.swt.widgets.Display;
13-
import org.eclipse.swt.widgets.Label;
14-
import org.eclipse.swt.widgets.ScrollBar;
1512
import org.eclipse.swt.widgets.Shell;
16-
import org.eclipse.swt.widgets.Slider;
1713

1814
public class TestScrollBar extends Shell {
1915

@@ -78,7 +74,6 @@ protected void createContents() {
7874
new Button(composite_2, SWT.PUSH).setText("Hello World");
7975
composite_2.getVerticalBar().addSelectionListener(new SelectionAdapter() {
8076

81-
@Override
8277
public void widgetSelected(SelectionEvent e) {
8378
System.out.println(composite_2.getVerticalBar().getSelection());
8479
}
@@ -89,7 +84,6 @@ public void widgetSelected(SelectionEvent e) {
8984
//composite_2.getHorizontalBar().setSelection(80);
9085
composite_2.getHorizontalBar().addSelectionListener(new SelectionAdapter() {
9186

92-
@Override
9387
public void widgetSelected(SelectionEvent e) {
9488
System.out.println(composite_2.getHorizontalBar().getSelection());
9589
}
@@ -101,7 +95,6 @@ public void widgetSelected(SelectionEvent e) {
10195
composite_2.getHorizontalBar().setMaximum(40);
10296
}
10397

104-
@Override
10598
protected void checkSubclass() {
10699
// Disable the check that prevents subclassing of SWT components
107100
}

tests/net.sf.j2s.test.swt/src/net/sf/j2s/test/swt/widgets/TestShell.java

Lines changed: 37 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616
* For a list of all SWT example snippets see
1717
* http://www.eclipse.org/swt/snippets/
1818
*/
19-
import java.util.Date;
2019
import org.eclipse.swt.*;
2120
import org.eclipse.swt.widgets.*;
22-
import org.eclipse.swt.events.MouseEvent;
23-
import org.eclipse.swt.events.MouseMoveListener;
2421
import org.eclipse.swt.events.SelectionAdapter;
2522
import org.eclipse.swt.events.SelectionEvent;
2623
import org.eclipse.swt.graphics.Color;
@@ -30,8 +27,9 @@ public class TestShell {
3027

3128
public 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

Comments
 (0)