Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit 0fa3c6a

Browse files
author
duke
committedJul 28, 2020
Automatic merge of client:master into master
2 parents b74b492 + 7a904f3 commit 0fa3c6a

File tree

2 files changed

+109
-127
lines changed

2 files changed

+109
-127
lines changed
 

‎test/jdk/ProblemList.txt

-2
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,6 @@ javax/swing/JPopupMenu/8075063/ContextMenuScrollTest.java 202880 linux-all
825825
javax/swing/dnd/8139050/NativeErrorsInTableDnD.java 8202765 macosx-all,linux-all
826826
javax/swing/Popup/TaskbarPositionTest.java 8065097 macosx-all,linux-all
827827
javax/swing/JEditorPane/6917744/bug6917744.java 8213124 macosx-all
828-
javax/swing/JTable/6263446/bug6263446.java 8169959 macosx-all
829828
javax/swing/JTree/6263446/bug6263446.java 8213125 macosx-all
830829
javax/swing/ToolTipManager/Test6256140.java 8233560 macosx-all
831830
javax/swing/text/View/8014863/bug8014863.java 8233561 macosx-all
@@ -848,7 +847,6 @@ javax/swing/JMenu/4692443/bug4692443.java 8171998 macosx-all
848847
javax/swing/plaf/synth/7158712/bug7158712.java 8238720 windows-all
849848
javax/swing/plaf/basic/BasicComboPopup/JComboBoxPopupLocation/JComboBoxPopupLocation.java 8238720 windows-all
850849
javax/swing/plaf/basic/BasicComboPopup/7072653/bug7072653.java 8238720 windows-all
851-
javax/swing/JTable/6263446/bug6263446.java 8238720 windows-all
852850

853851
sanity/client/SwingSet/src/ToolTipDemoTest.java 8225012 windows-all,macosx-all
854852
sanity/client/SwingSet/src/ScrollPaneDemoTest.java 8225013 linux-all

‎test/jdk/javax/swing/JTable/6263446/bug6263446.java

+109-125
Original file line numberDiff line numberDiff line change
@@ -29,197 +29,178 @@
2929
* @author Shannon Hickey
3030
* @run main bug6263446
3131
*/
32-
import java.awt.*;
33-
import java.awt.event.*;
34-
import javax.swing.*;
35-
import javax.swing.table.*;
32+
import java.awt.Point;
33+
import java.awt.Robot;
34+
import java.awt.Rectangle;
35+
import java.awt.event.InputEvent;
36+
import javax.swing.DefaultCellEditor;
37+
import javax.swing.JFrame;
38+
import javax.swing.JTable;
39+
import javax.swing.JTextField;
40+
import javax.swing.SwingUtilities;
41+
import javax.swing.table.TableModel;
42+
import javax.swing.table.DefaultTableModel;
3643

3744
public class bug6263446 {
3845

46+
private static JFrame frame;
3947
private static JTable table;
4048
private static final String FIRST = "AAAAA";
4149
private static final String SECOND = "BB";
4250
private static final String ALL = FIRST + " " + SECOND;
4351
private static Robot robot;
4452

4553
public static void main(String[] args) throws Exception {
46-
robot = new Robot();
47-
robot.setAutoDelay(50);
54+
try {
55+
robot = new Robot();
56+
robot.setAutoDelay(50);
4857

49-
SwingUtilities.invokeAndWait(new Runnable() {
50-
51-
public void run() {
52-
createAndShowGUI();
53-
}
54-
});
58+
SwingUtilities.invokeAndWait(() -> createAndShowGUI());
59+
robot.waitForIdle();
60+
robot.delay(1000);
5561

62+
Point point = getClickPoint();
63+
robot.mouseMove(point.x, point.y);
64+
robot.waitForIdle();
5665

57-
robot.waitForIdle();
58-
59-
Point point = getClickPoint();
60-
robot.mouseMove(point.x, point.y);
61-
robot.waitForIdle();
62-
63-
click(1);
64-
robot.waitForIdle();
65-
assertEditing(false);
66-
67-
click(2);
68-
robot.waitForIdle();
69-
checkSelectedText(null);
66+
click(1);
67+
robot.waitForIdle();
68+
assertEditing(false);
7069

71-
click(3);
72-
robot.waitForIdle();
73-
checkSelectedText(FIRST);
70+
click(2);
71+
robot.waitForIdle();
72+
checkSelectedText(null);
7473

74+
click(3);
75+
robot.waitForIdle();
76+
checkSelectedText(FIRST);
7577

76-
click(4);
77-
robot.waitForIdle();
78-
checkSelectedText(ALL);
78+
click(4);
79+
robot.waitForIdle();
80+
checkSelectedText(ALL);
7981

80-
setClickCountToStart(1);
82+
setClickCountToStart(1);
83+
robot.waitForIdle();
8184

82-
click(1);
83-
robot.waitForIdle();
84-
checkSelectedText(null);
85+
click(1);
86+
robot.waitForIdle();
87+
checkSelectedText(null);
8588

86-
click(2);
87-
robot.waitForIdle();
88-
checkSelectedText(FIRST);
89+
click(2);
90+
robot.waitForIdle();
91+
checkSelectedText(FIRST);
8992

90-
click(3);
91-
robot.waitForIdle();
92-
checkSelectedText(ALL);
93+
click(3);
94+
robot.waitForIdle();
95+
checkSelectedText(ALL);
9396

94-
setClickCountToStart(3);
97+
setClickCountToStart(3);
98+
robot.waitForIdle();
9599

96-
click(1);
97-
robot.waitForIdle();
98-
assertEditing(false);
100+
click(1);
101+
robot.waitForIdle();
102+
assertEditing(false);
99103

100-
click(2);
101-
robot.waitForIdle();
102-
assertEditing(false);
104+
click(2);
105+
robot.waitForIdle();
106+
assertEditing(false);
103107

104-
click(3);
105-
robot.waitForIdle();
106-
checkSelectedText(null);
108+
click(3);
109+
robot.waitForIdle();
110+
checkSelectedText(null);
107111

108-
click(4);
109-
robot.waitForIdle();
110-
checkSelectedText(FIRST);
112+
click(4);
113+
robot.waitForIdle();
114+
checkSelectedText(FIRST);
111115

112-
click(5);
113-
robot.waitForIdle();
114-
checkSelectedText(ALL);
116+
click(5);
117+
robot.waitForIdle();
118+
checkSelectedText(ALL);
115119

120+
SwingUtilities.invokeAndWait(() -> table.editCellAt(0, 0));
116121

117-
SwingUtilities.invokeAndWait(new Runnable() {
122+
robot.waitForIdle();
123+
assertEditing(true);
118124

119-
@Override
120-
public void run() {
121-
table.editCellAt(0, 0);
125+
click(2);
126+
robot.waitForIdle();
127+
checkSelectedText(FIRST);
128+
} finally {
129+
if (frame != null) {
130+
SwingUtilities.invokeAndWait(frame::dispose);
122131
}
123-
});
124-
125-
robot.waitForIdle();
126-
assertEditing(true);
127-
128-
click(2);
129-
robot.waitForIdle();
130-
checkSelectedText(FIRST);
131-
132+
}
132133
}
133134

134135
private static void checkSelectedText(String sel) throws Exception {
135136
assertEditing(true);
136137
checkSelection(sel);
138+
robot.waitForIdle();
137139
cancelCellEditing();
140+
robot.waitForIdle();
138141
assertEditing(false);
139142
}
140143

141144
private static void setClickCountToStart(final int clicks) throws Exception {
142-
SwingUtilities.invokeAndWait(new Runnable() {
143-
144-
@Override
145-
public void run() {
146-
DefaultCellEditor editor =
147-
(DefaultCellEditor) table.getDefaultEditor(String.class);
148-
editor.setClickCountToStart(clicks);
149-
}
145+
SwingUtilities.invokeAndWait(() -> {
146+
DefaultCellEditor editor =
147+
(DefaultCellEditor) table.getDefaultEditor(String.class);
148+
editor.setClickCountToStart(clicks);
150149
});
151-
152150
}
153151

154152
private static void cancelCellEditing() throws Exception {
155-
SwingUtilities.invokeAndWait(new Runnable() {
156-
157-
@Override
158-
public void run() {
159-
table.getCellEditor().cancelCellEditing();
160-
}
153+
SwingUtilities.invokeAndWait(() -> {
154+
table.getCellEditor().cancelCellEditing();
161155
});
162156
}
163157

164158
private static void checkSelection(final String sel) throws Exception {
165-
SwingUtilities.invokeAndWait(new Runnable() {
166-
167-
@Override
168-
public void run() {
169-
DefaultCellEditor editor =
170-
(DefaultCellEditor) table.getDefaultEditor(String.class);
171-
JTextField field = (JTextField) editor.getComponent();
172-
String text = field.getSelectedText();
173-
if (sel == null) {
174-
if (text != null && text.length() != 0) {
175-
throw new RuntimeException("Nothing should be selected,"
176-
+ " but \"" + text + "\" is selected.");
177-
}
178-
} else if (!sel.equals(text)) {
179-
throw new RuntimeException("\"" + sel + "\" should be "
180-
+ "selected, but \"" + text + "\" is selected.");
159+
SwingUtilities.invokeAndWait(() -> {
160+
DefaultCellEditor editor =
161+
(DefaultCellEditor) table.getDefaultEditor(String.class);
162+
JTextField field = (JTextField) editor.getComponent();
163+
String text = field.getSelectedText();
164+
if (sel == null) {
165+
if (text != null && text.length() != 0) {
166+
throw new RuntimeException("Nothing should be selected,"
167+
+ " but \"" + text + "\" is selected.");
181168
}
169+
} else if (!sel.equals(text)) {
170+
throw new RuntimeException("\"" + sel + "\" should be "
171+
+ "selected, but \"" + text + "\" is selected.");
182172
}
183173
});
184174
}
185175

186176
private static void assertEditing(final boolean editing) throws Exception {
187-
SwingUtilities.invokeAndWait(new Runnable() {
188-
189-
@Override
190-
public void run() {
191-
if (editing && !table.isEditing()) {
192-
throw new RuntimeException("Table should be editing");
193-
}
194-
if (!editing && table.isEditing()) {
195-
throw new RuntimeException("Table should not be editing");
196-
}
177+
SwingUtilities.invokeAndWait(() -> {
178+
if (editing && !table.isEditing()) {
179+
throw new RuntimeException("Table should be editing");
180+
}
181+
if (!editing && table.isEditing()) {
182+
throw new RuntimeException("Table should not be editing");
197183
}
198184
});
199185
}
200186

201187
private static Point getClickPoint() throws Exception {
202188
final Point[] result = new Point[1];
203-
SwingUtilities.invokeAndWait(new Runnable() {
204-
205-
@Override
206-
public void run() {
207-
Rectangle rect = table.getCellRect(0, 0, false);
208-
Point point = new Point(rect.x + rect.width / 5,
209-
rect.y + rect.height / 2);
210-
SwingUtilities.convertPointToScreen(point, table);
211-
result[0] = point;
212-
}
189+
SwingUtilities.invokeAndWait(() -> {
190+
Rectangle rect = table.getCellRect(0, 0, false);
191+
Point point = new Point(rect.x + rect.width / 5,
192+
rect.y + rect.height / 2);
193+
SwingUtilities.convertPointToScreen(point, table);
194+
result[0] = point;
213195
});
214-
215196
return result[0];
216197
}
217198

218199
private static void click(int times) {
219200
robot.delay(500);
220201
for (int i = 0; i < times; i++) {
221-
robot.mousePress(InputEvent.BUTTON1_MASK);
222-
robot.mouseRelease(InputEvent.BUTTON1_MASK);
202+
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
203+
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
223204
}
224205
}
225206

@@ -231,11 +212,14 @@ private static TableModel createTableModel() {
231212
}
232213

233214
private static void createAndShowGUI() {
234-
JFrame frame = new JFrame("bug6263446");
215+
frame = new JFrame("bug6263446");
235216
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
236217
table = new JTable(createTableModel());
237218
frame.add(table);
219+
frame.setAlwaysOnTop(true);
220+
frame.setLocationRelativeTo(null);
238221
frame.pack();
239222
frame.setVisible(true);
223+
frame.toFront();
240224
}
241225
}

0 commit comments

Comments
 (0)
This repository has been archived.