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 /* @test 25 @bug 6921687 8079428 26 @summary Mnemonic disappears after repeated attempts to open menu items using 27 mnemonics 28 @author Semyon Sadetsky 29 @library /lib/testlibrary 30 @build jdk.testlibrary.OSInfo 31 @run main bug6921687 32 */ 33 34 35 import jdk.testlibrary.OSInfo; 36 import javax.swing.*; 37 import java.awt.*; 38 import java.awt.event.KeyEvent; 39 40 41 public class bug6921687 { 42 43 private static Class lafClass; 44 private static JFrame frame; 45 46 public static void main(String[] args) throws Exception { 47 if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) { 48 System.out.println("Only Windows platform test. Test is skipped."); 49 System.out.println("ok"); 50 return; 51 } 52 lafClass = Class.forName(UIManager.getSystemLookAndFeelClassName()); 53 UIManager.setLookAndFeel((LookAndFeel) lafClass.newInstance()); 54 try { 55 SwingUtilities.invokeAndWait(new Runnable() { 56 public void run() { 57 frame = new JFrame(); 58 frame.setUndecorated(true); 59 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 60 setup(frame); 61 } 62 }); 63 64 final Robot robot = new Robot(); 65 robot.setAutoDelay(20); 66 robot.keyPress(KeyEvent.VK_ALT); 67 robot.keyPress(KeyEvent.VK_F); 68 robot.keyRelease(KeyEvent.VK_F); 69 robot.keyRelease(KeyEvent.VK_ALT); 70 robot.waitForIdle(); 71 checkMnemonics(); 72 73 robot.keyPress(KeyEvent.VK_ALT); 74 robot.keyPress(KeyEvent.VK_S); 75 robot.keyRelease(KeyEvent.VK_S); 76 robot.keyRelease(KeyEvent.VK_ALT); 77 robot.waitForIdle(); 78 checkMnemonics(); 79 System.out.println("ok"); 80 } finally { 81 frame.dispose(); 82 } 83 84 } | 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 /lib/testlibrary 31 * @build jdk.testlibrary.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.UIManager; 43 import jdk.testlibrary.Platform; 44 45 public class bug6921687 { 46 47 private static Class lafClass; 48 private static JFrame frame; 49 50 public static void main(String[] args) throws Exception { 51 if (!Platform.isWindows()) { 52 System.out.println("Only Windows platform test. Test is skipped."); 53 System.out.println("ok"); 54 return; 55 } 56 final String lafClassName = UIManager.getSystemLookAndFeelClassName(); 57 lafClass = Class.forName(lafClassName); 58 UIManager.setLookAndFeel(lafClassName); 59 try { 60 frame = new JFrame(); 61 frame.setUndecorated(true); 62 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 63 setup(frame); 64 65 final Robot robot = new Robot(); 66 robot.waitForIdle(); 67 robot.setAutoDelay(20); 68 robot.keyPress(KeyEvent.VK_ALT); 69 robot.keyPress(KeyEvent.VK_F); 70 robot.keyRelease(KeyEvent.VK_F); 71 robot.keyRelease(KeyEvent.VK_ALT); 72 robot.waitForIdle(); 73 checkMnemonics(); 74 75 robot.keyPress(KeyEvent.VK_ALT); 76 robot.keyPress(KeyEvent.VK_S); 77 robot.keyRelease(KeyEvent.VK_S); 78 robot.keyRelease(KeyEvent.VK_ALT); 79 robot.waitForIdle(); 80 checkMnemonics(); 81 System.out.println("ok"); 82 } finally { 83 frame.dispose(); 84 } 85 86 } |