equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
24 /* |
24 /* |
25 @test |
25 @test |
26 @key headful |
26 @key headful |
27 @bug 4782886 |
27 @bug 4782886 |
28 @summary FocusManager consumes wrong KEY_TYPED events |
28 @summary FocusManager consumes wrong KEY_TYPED events |
29 @author Oleg.Sukhodolsky: area=awt.focus |
|
30 @library ../../regtesthelpers |
29 @library ../../regtesthelpers |
31 @build Util |
30 @build Util |
32 @run main WrongKeyTypedConsumedTest |
31 @run main WrongKeyTypedConsumedTest |
33 */ |
32 */ |
34 |
33 |
35 import java.applet.Applet; |
|
36 import java.awt.AWTException; |
|
37 import java.awt.AWTKeyStroke; |
34 import java.awt.AWTKeyStroke; |
38 import java.awt.BorderLayout; |
35 import java.awt.BorderLayout; |
39 import java.awt.Dialog; |
|
40 import java.awt.Dimension; |
|
41 import java.awt.FlowLayout; |
|
42 import java.awt.Frame; |
|
43 import java.awt.KeyboardFocusManager; |
36 import java.awt.KeyboardFocusManager; |
44 import java.awt.Point; |
|
45 import java.awt.Robot; |
37 import java.awt.Robot; |
46 import java.awt.TextArea; |
|
47 |
38 |
48 import java.awt.event.KeyEvent; |
39 import java.awt.event.KeyEvent; |
49 |
40 |
50 import java.util.HashSet; |
41 import java.util.HashSet; |
51 import java.util.Set; |
42 import java.util.Set; |
54 import javax.swing.JFrame; |
45 import javax.swing.JFrame; |
55 import javax.swing.JTextArea; |
46 import javax.swing.JTextArea; |
56 |
47 |
57 import test.java.awt.regtesthelpers.Util; |
48 import test.java.awt.regtesthelpers.Util; |
58 |
49 |
59 public class WrongKeyTypedConsumedTest extends Applet |
50 public class WrongKeyTypedConsumedTest |
60 { |
51 { |
61 Robot robot = Util.createRobot(); |
52 Robot robot = Util.createRobot(); |
62 |
53 |
63 public static void main(String[] args) { |
54 public static void main(String[] args) { |
64 WrongKeyTypedConsumedTest test = new WrongKeyTypedConsumedTest(); |
55 WrongKeyTypedConsumedTest test = new WrongKeyTypedConsumedTest(); |
65 test.start(); |
56 test.start(); |
66 } |
57 } |
67 |
58 |
68 public void start () |
59 public void start () |
69 { |
60 { |
70 setSize (200,200); |
|
71 setVisible(true); |
|
72 validate(); |
|
73 |
|
74 JFrame frame = new JFrame("The Frame"); |
61 JFrame frame = new JFrame("The Frame"); |
75 Set ftk = new HashSet(); |
62 Set ftk = new HashSet(); |
76 ftk.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_DOWN, 0)); |
63 ftk.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_DOWN, 0)); |
77 frame.getContentPane(). |
64 frame.getContentPane(). |
78 setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, |
65 setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, |
83 |
70 |
84 JTextArea textarea = new JTextArea(40, 10); |
71 JTextArea textarea = new JTextArea(40, 10); |
85 frame.getContentPane().add(textarea); |
72 frame.getContentPane().add(textarea); |
86 |
73 |
87 frame.pack(); |
74 frame.pack(); |
|
75 frame.setLocationRelativeTo(null); |
88 frame.setVisible(true); |
76 frame.setVisible(true); |
89 Util.waitForIdle(robot); |
77 Util.waitForIdle(robot); |
90 |
78 |
91 if (!frame.isActive()) { |
79 if (!frame.isActive()) { |
92 throw new RuntimeException("Test Fialed: frame isn't active"); |
80 throw new RuntimeException("Test Fialed: frame isn't active"); |