Skip to content

Commit af92bc0

Browse files
committed
tests and SwingJS-site.zip
1 parent ba17936 commit af92bc0

File tree

9 files changed

+84
-5
lines changed

9 files changed

+84
-5
lines changed
6.57 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200506131724
1+
20200516014108
6.57 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200506131724
1+
20200516014108
6.57 KB
Binary file not shown.

sources/net.sf.j2s.java.core/src/test/JalviewJSTest.java

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager
121121
super.processKeyEvent(e, path, m);
122122
}
123123
};
124-
124+
125125
int nAction = 0;
126126

127127
ActionListener listener = new ActionListener() {
@@ -197,6 +197,27 @@ public void keyReleased(KeyEvent e) {
197197
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
198198

199199
menu = new JMenu("TESTING");
200+
201+
menu.addMenuListener(new MenuListener() {
202+
203+
@Override
204+
public void menuSelected(MenuEvent e) {
205+
System.out.println("menu MenuListener sel " + e);
206+
}
207+
208+
@Override
209+
public void menuDeselected(MenuEvent e) {
210+
System.out.println("menu MenuListener des " + e);
211+
}
212+
213+
@Override
214+
public void menuCanceled(MenuEvent e) {
215+
System.out.println("menu MenuListener can " + e);
216+
}
217+
218+
});
219+
220+
200221
menu1 = new JMenu("testing1");
201222
menu2 = new JMenu("testing2");
202223
menu.setHorizontalAlignment(SwingConstants.RIGHT);
@@ -591,6 +612,27 @@ public void actionPerformed(ActionEvent e) {
591612
mRight.add(rb1m);
592613
// mRight.addMenuListener(this);
593614

615+
616+
mRight.addMenuListener(new MenuListener() {
617+
618+
@Override
619+
public void menuSelected(MenuEvent e) {
620+
System.out.println("mRight MenuListener sel " + e);
621+
}
622+
623+
@Override
624+
public void menuDeselected(MenuEvent e) {
625+
System.out.println("mRight MenuListener des " + e);
626+
}
627+
628+
@Override
629+
public void menuCanceled(MenuEvent e) {
630+
System.out.println("mRight MenuListener can " + e);
631+
}
632+
633+
});
634+
635+
594636
btn = new JMenuItem("-");
595637
btn.setFont(font);
596638
mRight.add(btn);

sources/net.sf.j2s.java.core/src/test/Test_Dialog.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ public void propertyChange(PropertyChangeEvent event) {
8686
}
8787

8888
// JSComponent.DialogCaller interface
89-
public void onDialogReturn(int value) {
89+
public void onDialogReturn(int value) {
9090
if (value != Math.floor(value))
9191
return; // in JavaScript, this will be NaN
9292
System.out.println("int value is " + value);
93+
94+
status.setText("You chose option " + value);
9395
}
9496

9597
// JSComponent.DialogCaller interface
@@ -166,6 +168,20 @@ public void actionPerformed(ActionEvent e) {
166168
});
167169
p.add(b);
168170

171+
172+
b = new JButton("OptionDialog");
173+
b.addActionListener(new ActionListener() {
174+
175+
@Override
176+
public void actionPerformed(ActionEvent e) {
177+
Test_Dialog.this.onDialogReturn(JOptionPane.showOptionDialog(Test_Dialog.this, "Pick one of the following three options:", "Option title",
178+
0, 0, null, new Object[] {"Option A", "Option B", "Option C"} , "Option B"));
179+
}
180+
181+
});
182+
p.add(b);
183+
184+
169185
b = new JButton("FileOpenDialog");
170186
b.addActionListener(new ActionListener() {
171187

sources/net.sf.j2s.java.core/src/test/Test_Dialog2.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,28 @@ public void actionPerformed(ActionEvent e) {
137137
});
138138
p.add(b);
139139

140+
b = new JButton("OptionDialog");
141+
b.addActionListener(new ActionListener() {
142+
143+
@Override
144+
public void actionPerformed(ActionEvent e) {
145+
new AsyncDialog().showOptionDialog(Test_Dialog2.this, "Pick one of the following three options:", "Option title",
146+
0, 0, null, new Object[] {"Option A", "Option B", "Option C"} , "Option B", new ActionListener() {
147+
@Override
148+
public void actionPerformed(ActionEvent e) {
149+
String msg = "Option selected " + ((AsyncDialog)e.getSource()).getValue() + " (" + e.getActionCommand() + ")";
150+
System.out.println(msg);
151+
status.setText(msg);
152+
}
153+
154+
});
155+
}
156+
157+
});
158+
p.add(b);
159+
160+
161+
140162
b = new JButton("FileOpenDialog");
141163
b.addActionListener(new ActionListener() {
142164

sources/net.sf.j2s.java.core/src/test/components/ListDemoAWT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ private static void createAndShowGUI() {
262262
frame.setVisible(true);
263263
demo.checkPeer();
264264

265-
266265
}
267266

268267
private void checkPeer() {

0 commit comments

Comments
 (0)