# HG changeset patch # User yan # Date 1442914010 -10800 # Node ID 234e264e9265f498eb83310cb1cbe923f1e35422 # Parent f9cb6e427f9ec77ffedfdea1f42b3d4f47bcbc81 8132380: Do not create LaF instance in javax/swing/plaf/windows/6921687/bug6921687.java Reviewed-by: yan, ssadetsky Contributed-by: Renjith Alexander diff -r f9cb6e427f9e -r 234e264e9265 jdk/test/javax/swing/plaf/windows/6921687/bug6921687.java --- a/jdk/test/javax/swing/plaf/windows/6921687/bug6921687.java Sat Sep 19 15:45:59 2015 -0700 +++ b/jdk/test/javax/swing/plaf/windows/6921687/bug6921687.java Tue Sep 22 12:26:50 2015 +0300 @@ -21,22 +21,27 @@ * questions. */ -/* @test - @bug 6921687 8079428 - @summary Mnemonic disappears after repeated attempts to open menu items using - mnemonics - @author Semyon Sadetsky - @library /lib/testlibrary - @build jdk.testlibrary.OSInfo - @run main bug6921687 - */ - - -import jdk.testlibrary.OSInfo; -import javax.swing.*; -import java.awt.*; +/* + * @test + * @bug 6921687 8079428 + * @summary Mnemonic disappears after repeated attempts to open menu items using + * mnemonics + * @author Semyon Sadetsky + * @library /lib/testlibrary + * @build jdk.testlibrary.Platform + * @requires (os.family == "windows") + * @modules java.desktop/com.sun.java.swing.plaf.windows + * @run main bug6921687 + */ +import java.awt.Robot; import java.awt.event.KeyEvent; - +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import jdk.testlibrary.Platform; public class bug6921687 { @@ -44,24 +49,24 @@ private static JFrame frame; public static void main(String[] args) throws Exception { - if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) { + if (!Platform.isWindows()) { System.out.println("Only Windows platform test. Test is skipped."); System.out.println("ok"); return; } - lafClass = Class.forName(UIManager.getSystemLookAndFeelClassName()); - UIManager.setLookAndFeel((LookAndFeel) lafClass.newInstance()); + final String lafClassName = UIManager.getSystemLookAndFeelClassName(); + lafClass = Class.forName(lafClassName); + UIManager.setLookAndFeel(lafClassName); try { - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame = new JFrame(); - frame.setUndecorated(true); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - setup(frame); - } + SwingUtilities.invokeAndWait(() -> { + frame = new JFrame(); + frame.setUndecorated(true); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setup(frame); }); final Robot robot = new Robot(); + robot.waitForIdle(); robot.setAutoDelay(20); robot.keyPress(KeyEvent.VK_ALT); robot.keyPress(KeyEvent.VK_F); @@ -108,6 +113,5 @@ frame.setSize(350, 250); frame.setVisible(true); - } }