4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6921687 8079428
27 * @summary Mnemonic disappears after repeated attempts to open menu items using
28 * mnemonics
29 * @author Semyon Sadetsky
30 * @library /test/lib
31 * @build jdk.test.lib.Platform
32 * @requires (os.family == "windows")
33 * @modules java.desktop/com.sun.java.swing.plaf.windows
34 * @run main bug6921687
35 */
36 import java.awt.Robot;
37 import java.awt.event.KeyEvent;
38 import javax.swing.JFrame;
39 import javax.swing.JMenu;
40 import javax.swing.JMenuBar;
41 import javax.swing.JMenuItem;
42 import javax.swing.SwingUtilities;
43 import javax.swing.UIManager;
44 import jdk.test.lib.Platform;
45
46 public class bug6921687 {
47
48 private static Class lafClass;
49 private static JFrame frame;
50
51 public static void main(String[] args) throws Exception {
52 if (!Platform.isWindows()) {
53 System.out.println("Only Windows platform test. Test is skipped.");
54 System.out.println("ok");
55 return;
66 });
67
68 final Robot robot = new Robot();
69 robot.waitForIdle();
70 robot.setAutoDelay(20);
71 robot.keyPress(KeyEvent.VK_ALT);
72 robot.keyPress(KeyEvent.VK_F);
73 robot.keyRelease(KeyEvent.VK_F);
74 robot.keyRelease(KeyEvent.VK_ALT);
75 robot.waitForIdle();
76 checkMnemonics();
77
78 robot.keyPress(KeyEvent.VK_ALT);
79 robot.keyPress(KeyEvent.VK_S);
80 robot.keyRelease(KeyEvent.VK_S);
81 robot.keyRelease(KeyEvent.VK_ALT);
82 robot.waitForIdle();
83 checkMnemonics();
84 System.out.println("ok");
85 } finally {
86 frame.dispose();
87 }
88
89 }
90
91 private static void checkMnemonics() throws Exception {
92 if ((Boolean) lafClass.getMethod("isMnemonicHidden").invoke(lafClass)) {
93 throw new RuntimeException("Mnemonics are hidden");
94 }
95 }
96
97 private static void setup(JFrame frame) {
98 JMenuBar menuBar = new JMenuBar();
99 frame.setJMenuBar(menuBar);
100
101 // First Menu, F - Mnemonic
102 JMenu firstMenu = new JMenu("First Menu");
103 firstMenu.setMnemonic(KeyEvent.VK_F);
104 firstMenu.add(new JMenuItem("One", KeyEvent.VK_O));
105 firstMenu.add(new JMenuItem("Two", KeyEvent.VK_T));
106 menuBar.add(firstMenu);
|
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test
26 * @key headful
27 * @bug 6921687 8079428
28 * @summary Mnemonic disappears after repeated attempts to open menu items using
29 * mnemonics
30 * @author Semyon Sadetsky
31 * @library /test/lib
32 * @build jdk.test.lib.Platform
33 * @requires (os.family == "windows")
34 * @modules java.desktop/com.sun.java.swing.plaf.windows
35 * @run main bug6921687
36 */
37
38 import java.awt.Robot;
39 import java.awt.event.KeyEvent;
40 import javax.swing.JFrame;
41 import javax.swing.JMenu;
42 import javax.swing.JMenuBar;
43 import javax.swing.JMenuItem;
44 import javax.swing.SwingUtilities;
45 import javax.swing.UIManager;
46 import jdk.test.lib.Platform;
47
48 public class bug6921687 {
49
50 private static Class lafClass;
51 private static JFrame frame;
52
53 public static void main(String[] args) throws Exception {
54 if (!Platform.isWindows()) {
55 System.out.println("Only Windows platform test. Test is skipped.");
56 System.out.println("ok");
57 return;
68 });
69
70 final Robot robot = new Robot();
71 robot.waitForIdle();
72 robot.setAutoDelay(20);
73 robot.keyPress(KeyEvent.VK_ALT);
74 robot.keyPress(KeyEvent.VK_F);
75 robot.keyRelease(KeyEvent.VK_F);
76 robot.keyRelease(KeyEvent.VK_ALT);
77 robot.waitForIdle();
78 checkMnemonics();
79
80 robot.keyPress(KeyEvent.VK_ALT);
81 robot.keyPress(KeyEvent.VK_S);
82 robot.keyRelease(KeyEvent.VK_S);
83 robot.keyRelease(KeyEvent.VK_ALT);
84 robot.waitForIdle();
85 checkMnemonics();
86 System.out.println("ok");
87 } finally {
88 if (frame != null) { frame.dispose(); }
89 }
90
91 }
92
93 private static void checkMnemonics() throws Exception {
94 if ((Boolean) lafClass.getMethod("isMnemonicHidden").invoke(lafClass)) {
95 throw new RuntimeException("Mnemonics are hidden");
96 }
97 }
98
99 private static void setup(JFrame frame) {
100 JMenuBar menuBar = new JMenuBar();
101 frame.setJMenuBar(menuBar);
102
103 // First Menu, F - Mnemonic
104 JMenu firstMenu = new JMenu("First Menu");
105 firstMenu.setMnemonic(KeyEvent.VK_F);
106 firstMenu.add(new JMenuItem("One", KeyEvent.VK_O));
107 firstMenu.add(new JMenuItem("Two", KeyEvent.VK_T));
108 menuBar.add(firstMenu);
|