20 * or visit www.oracle.com if you need additional information or have any |
20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 /* |
24 /* |
25 @test %W% %E% |
25 @test |
26 @key headful |
26 @key headful |
27 @bug 6598089 |
27 @bug 6598089 |
28 @summary Tests restoring focus on a single disabled coponent |
28 @summary Tests restoring focus on a single disabled coponent |
29 @author Anton Tarasov: area=awt-focus |
|
30 @library ../../regtesthelpers |
29 @library ../../regtesthelpers |
31 @build Util |
30 @build Util |
32 @run main RestoreFocusOnDisabledComponentTest |
31 @run main RestoreFocusOnDisabledComponentTest |
33 */ |
32 */ |
34 |
33 |
35 import java.awt.*; |
34 import java.awt.*; |
36 import java.awt.event.*; |
35 import java.awt.event.*; |
37 import java.applet.Applet; |
|
38 import test.java.awt.regtesthelpers.Util; |
36 import test.java.awt.regtesthelpers.Util; |
39 |
37 |
40 /* |
38 /* |
41 * The bug is not reproducible on Windows. |
39 * The bug is not reproducible on Windows. |
42 */ |
40 */ |
43 public class RestoreFocusOnDisabledComponentTest extends Applet { |
41 public class RestoreFocusOnDisabledComponentTest { |
44 Frame frame = new Frame("Frame") {public String toString() {return "FRAME";}}; |
42 Frame frame = new Frame("Frame") {public String toString() {return "FRAME";}}; |
45 Button b0 = new Button("button0") {public String toString() {return "B-0";}}; |
43 Button b0 = new Button("button0") {public String toString() {return "B-0";}}; |
46 Button b1 = new Button("button1") {public String toString() {return "B-1";}}; |
44 Button b1 = new Button("button1") {public String toString() {return "B-1";}}; |
47 volatile int nFocused; |
45 volatile int nFocused; |
48 Robot robot; |
46 Robot robot; |
60 public void start() { |
58 public void start() { |
61 frame.add(b0); |
59 frame.add(b0); |
62 frame.add(b1); |
60 frame.add(b1); |
63 frame.setLayout(new FlowLayout()); |
61 frame.setLayout(new FlowLayout()); |
64 frame.pack(); |
62 frame.pack(); |
65 |
63 frame.setLocationRelativeTo(null); |
66 frame.setVisible(true); |
64 frame.setVisible(true); |
67 |
65 |
68 Util.waitForIdle(robot); |
66 Util.waitForIdle(robot); |
69 KeyboardFocusManager.setCurrentKeyboardFocusManager(new DefaultKeyboardFocusManager() { |
67 KeyboardFocusManager.setCurrentKeyboardFocusManager(new DefaultKeyboardFocusManager() { |
70 public boolean dispatchEvent(AWTEvent e) { |
68 public boolean dispatchEvent(AWTEvent e) { |