author | serb |
Tue, 12 Nov 2013 20:24:25 +0400 | |
changeset 21596 | 0e3a39f29dbc |
parent 14856 | 92a1bcf46888 |
child 23010 | 6dadb192ad81 |
permissions | -rw-r--r-- |
13652
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
1 |
/* |
14856 | 2 |
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
13652
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
4 |
* |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
21596 | 7 |
* published by the Free Software Foundation. |
13652
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
8 |
* |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
13 |
* accompanied this code). |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
14 |
* |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
18 |
* |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
21 |
* questions. |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
22 |
*/ |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
23 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
24 |
/* |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
25 |
* @test |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
26 |
* @bug 6981400 |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
27 |
* @summary Tabbing between textfiled do not work properly when ALT+TAB |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
28 |
* @author anton.tarasov |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
29 |
* @library ../../regtesthelpers |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
30 |
* @build Util |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
31 |
* @run main Test1 |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
32 |
*/ |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
33 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
34 |
// This test shows a frame with four focusable components: b0, b1, b2, b3. |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
35 |
// Then it presses Tab three times. EDT is freezed for a while on the first FOCUS_LOST event. |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
36 |
// Meantime, the test clicks in a component of another frame and then clicks in the title |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
37 |
// of the original frame. When EDT awakes and all the queued events get processed, |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
38 |
// the other frame should ones gain focus and then pass it to the original frame. |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
39 |
// The b3 component of the orinial frame should finally become a focus owner. |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
40 |
// The FOCUS_LOST/FOCUS_GAINED events order in the original frame is tracked and should be: |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
41 |
// b0 -> b1 -> b2 -> b3. |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
42 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
43 |
import java.awt.*; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
44 |
import java.awt.event.*; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
45 |
import java.util.ArrayList; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
46 |
import java.util.Arrays; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
47 |
import java.util.List; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
48 |
import javax.swing.*; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
49 |
import test.java.awt.regtesthelpers.Util; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
50 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
51 |
public class Test1 { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
52 |
static JFrame f0 = new JFrame("base_frame") { public String getName() {return "base_frame";} }; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
53 |
static JButton f0b0 = new JB("b0"); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
54 |
static JButton f0b1 = new JB("b1"); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
55 |
static JButton f0b2 = new JB("b2"); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
56 |
static JButton f0b3 = new JB("b3"); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
57 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
58 |
static JFrame f1 = new JFrame("swing_frame") { public String getName() {return "swing_frame";} }; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
59 |
static JButton f1b0 = new JButton("button"); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
60 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
61 |
static Frame f2 = new Frame("awt_frame") { public String getName() {return "awt_frame";} }; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
62 |
static Button f2b0 = new Button("button"); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
63 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
64 |
static Robot robot; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
65 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
66 |
static List<Component> gainedList = new ArrayList<Component>(); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
67 |
static List<Component> lostList = new ArrayList<Component>(); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
68 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
69 |
static Component[] refGainedList = new Component[] {f0b1, f0b2, f0b3, f0b3}; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
70 |
static Component[] refLostList = new Component[] {f0b0, f0b1, f0b2, f0b3}; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
71 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
72 |
static boolean tracking; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
73 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
74 |
public static void main(String[] args) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
75 |
Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
76 |
public void eventDispatched(AWTEvent e) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
77 |
System.out.println(e); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
78 |
} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
79 |
}, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_EVENT_MASK); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
80 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
81 |
try { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
82 |
robot = new Robot(); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
83 |
} catch (AWTException ex) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
84 |
throw new RuntimeException("Error: can't create Robot"); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
85 |
} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
86 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
87 |
f0.add(f0b0); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
88 |
f0.add(f0b1); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
89 |
f0.add(f0b2); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
90 |
f0.add(f0b3); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
91 |
f0.setLayout(new FlowLayout()); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
92 |
f0.setBounds(0, 100, 400, 200); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
93 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
94 |
f1.add(f1b0); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
95 |
f1.setBounds(0, 400, 400, 200); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
96 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
97 |
f2.add(f2b0); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
98 |
f2.setBounds(0, 400, 400, 200); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
99 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
100 |
f0b0.addFocusListener(new FocusAdapter() { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
101 |
@Override |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
102 |
public void focusLost(FocusEvent e) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
103 |
try { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
104 |
Thread.sleep(1000); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
105 |
} catch (Exception ex) {} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
106 |
} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
107 |
}); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
108 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
109 |
// |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
110 |
// Case 1. Test against swing JFrame. |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
111 |
// |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
112 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
113 |
f1.setVisible(true); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
114 |
f0.setVisible(true); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
115 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
116 |
Util.waitForIdle(robot); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
117 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
118 |
if (!f0b0.isFocusOwner()) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
119 |
Util.clickOnComp(f0b0, robot); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
120 |
Util.waitForIdle(robot); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
121 |
if (!f0b0.isFocusOwner()) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
122 |
throw new RuntimeException("Error: can't focus the component " + f0b0); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
123 |
} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
124 |
} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
125 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
126 |
System.out.println("\nTest case 1: swing frame\n"); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
127 |
test(f1b0); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
128 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
129 |
// |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
130 |
// Case 2. Test against awt Frame. |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
131 |
// |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
132 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
133 |
tracking = false; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
134 |
gainedList.clear(); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
135 |
lostList.clear(); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
136 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
137 |
f1.dispose(); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
138 |
f2.setAutoRequestFocus(false); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
139 |
f2.setVisible(true); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
140 |
Util.waitForIdle(robot); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
141 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
142 |
Util.clickOnComp(f0b0, robot); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
143 |
Util.waitForIdle(robot); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
144 |
if (!f0b0.isFocusOwner()) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
145 |
throw new RuntimeException("Error: can't focus the component " + f0b0); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
146 |
} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
147 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
148 |
System.out.println("\nTest case 2: awt frame\n"); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
149 |
test(f2b0); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
150 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
151 |
System.out.println("\nTest passed."); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
152 |
} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
153 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
154 |
public static void test(Component compToClick) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
155 |
tracking = true; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
156 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
157 |
robot.keyPress(KeyEvent.VK_TAB); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
158 |
robot.delay(50); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
159 |
robot.keyRelease(KeyEvent.VK_TAB); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
160 |
robot.delay(50); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
161 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
162 |
robot.keyPress(KeyEvent.VK_TAB); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
163 |
robot.delay(50); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
164 |
robot.keyRelease(KeyEvent.VK_TAB); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
165 |
robot.delay(50); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
166 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
167 |
robot.keyPress(KeyEvent.VK_TAB); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
168 |
robot.delay(50); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
169 |
robot.keyRelease(KeyEvent.VK_TAB); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
170 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
171 |
robot.delay(50); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
172 |
Util.clickOnComp(compToClick, robot); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
173 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
174 |
robot.delay(50); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
175 |
Util.clickOnTitle(f0, robot); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
176 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
177 |
Util.waitForIdle(robot); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
178 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
179 |
if (!f0b3.isFocusOwner()) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
180 |
throw new RuntimeException("Test failed: f0b3 is not a focus owner"); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
181 |
} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
182 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
183 |
if (!"sun.awt.X11.XToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
184 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
185 |
if (!Arrays.asList(refGainedList).equals(gainedList)) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
186 |
System.out.println("gained list: " + gainedList); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
187 |
throw new RuntimeException("Test failed: wrong FOCUS_GAINED events order"); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
188 |
} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
189 |
if (!Arrays.asList(refLostList).equals(lostList)) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
190 |
System.out.println("lost list: " + lostList); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
191 |
throw new RuntimeException("Test failed: wrong FOCUS_LOST events order"); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
192 |
} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
193 |
} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
194 |
} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
195 |
} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
196 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
197 |
class JB extends JButton { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
198 |
String name; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
199 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
200 |
public JB(String name) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
201 |
super(name); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
202 |
this.name = name; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
203 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
204 |
addFocusListener(new FocusListener() { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
205 |
public void focusGained(FocusEvent e) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
206 |
if (Test1.tracking) |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
207 |
Test1.gainedList.add(e.getComponent()); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
208 |
} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
209 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
210 |
public void focusLost(FocusEvent e) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
211 |
if (Test1.tracking) |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
212 |
Test1.lostList.add(e.getComponent()); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
213 |
} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
214 |
}); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
215 |
} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
216 |
|
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
217 |
public String toString() { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
218 |
return "[" + name + "]"; |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
219 |
} |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
diff
changeset
|
220 |
} |