1
1
/*
2
- * Copyright (c) 2011, 2012 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2011, 2022 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
38
38
39
39
public class bug6263446 {
40
40
41
- private static final String FIRST = "AAAAAAAAAAA " ;
41
+ private static final String FIRST = "AAAAA " ;
42
42
private static final String SECOND = "BB" ;
43
43
private static final String ALL = FIRST + " " + SECOND ;
44
44
private static JTree tree ;
@@ -62,59 +62,75 @@ public void run() {
62
62
try {
63
63
Point point = getClickPoint ();
64
64
robot .mouseMove (point .x , point .y );
65
+ robot .waitForIdle ();
65
66
66
67
// click count 3
67
68
click (1 );
69
+ robot .waitForIdle ();
68
70
assertNotEditing ();
69
71
70
72
click (2 );
73
+ robot .waitForIdle ();
71
74
assertNotEditing ();
72
75
73
76
click (3 );
77
+ robot .waitForIdle ();
74
78
assertEditing ();
75
79
cancelCellEditing ();
76
80
assertNotEditing ();
77
81
78
82
click (4 );
83
+ robot .waitForIdle ();
79
84
checkSelectedText (FIRST );
80
85
81
86
click (5 );
87
+ robot .waitForIdle ();
82
88
checkSelectedText (ALL );
83
89
84
90
// click count 4
85
91
setClickCountToStart (4 );
92
+ robot .waitForIdle ();
86
93
87
94
click (1 );
95
+ robot .waitForIdle ();
88
96
assertNotEditing ();
89
97
90
98
click (2 );
99
+ robot .waitForIdle ();
91
100
assertNotEditing ();
92
101
93
102
click (3 );
103
+ robot .waitForIdle ();
94
104
assertNotEditing ();
95
105
96
106
click (4 );
107
+ robot .waitForIdle ();
97
108
assertEditing ();
98
109
cancelCellEditing ();
99
110
assertNotEditing ();
100
111
101
112
click (5 );
113
+ robot .waitForIdle ();
102
114
checkSelectedText (FIRST );
103
115
104
116
click (6 );
117
+ robot .waitForIdle ();
105
118
checkSelectedText (ALL );
106
119
107
120
// start path editing
108
121
startPathEditing ();
109
122
assertEditing ();
110
123
111
124
click (1 );
125
+ robot .waitForIdle ();
112
126
checkSelection (null );
113
127
114
128
click (2 );
129
+ robot .waitForIdle ();
115
130
checkSelection (FIRST );
116
131
117
132
click (3 );
133
+ robot .waitForIdle ();
118
134
checkSelection (ALL );
119
135
} finally {
120
136
if (frame != null ) {
@@ -128,7 +144,6 @@ private static void click(int times) {
128
144
for (int i = 0 ; i < times ; i ++) {
129
145
robot .mousePress (InputEvent .BUTTON1_DOWN_MASK );
130
146
robot .mouseRelease (InputEvent .BUTTON1_DOWN_MASK );
131
- robot .waitForIdle ();
132
147
}
133
148
}
134
149
@@ -141,7 +156,7 @@ private static Point getClickPoint() throws Exception {
141
156
public void run () {
142
157
Rectangle rect = tree .getRowBounds (0 );
143
158
// UPDATE !!!
144
- Point p = new Point (rect .x + rect .width / 2 , rect .y + 2 );
159
+ Point p = new Point (rect .x + rect .width / 2 , rect .y + rect . height / 2 );
145
160
SwingUtilities .convertPointToScreen (p , tree );
146
161
result [0 ] = p ;
147
162
@@ -166,9 +181,11 @@ private static void createAndShowGUI() {
166
181
167
182
168
183
frame .getContentPane ().add (tree );
184
+ frame .setAlwaysOnTop (true );
169
185
frame .pack ();
170
186
frame .setLocationRelativeTo (null );
171
187
frame .setVisible (true );
188
+ frame .toFront ();
172
189
}
173
190
174
191
private static void setClickCountToStart (final int clicks ) throws Exception {
@@ -183,6 +200,7 @@ public void run() {
183
200
field .setAccessible (true );
184
201
DefaultCellEditor ce = (DefaultCellEditor ) field .get (editor );
185
202
ce .setClickCountToStart (clicks );
203
+
186
204
} catch (IllegalAccessException e ) {
187
205
throw new RuntimeException (e );
188
206
} catch (NoSuchFieldException e ) {
@@ -248,7 +266,9 @@ public void run() {
248
266
private static void checkSelectedText (String sel ) throws Exception {
249
267
assertEditing ();
250
268
checkSelection (sel );
269
+ robot .waitForIdle ();
251
270
cancelCellEditing ();
271
+ robot .waitForIdle ();
252
272
assertNotEditing ();
253
273
}
254
274
0 commit comments