< prev index next >
test/javax/swing/plaf/windows/6921687/bug6921687.java
Print this page
@@ -19,51 +19,56 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* 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
+/*
+ * @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 jdk.testlibrary.OSInfo;
-import javax.swing.*;
-import java.awt.*;
+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 {
private static Class lafClass;
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() {
+ 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);
robot.keyRelease(KeyEvent.VK_F);
robot.keyRelease(KeyEvent.VK_ALT);
@@ -106,8 +111,7 @@
secondMenu.add(new JMenuItem("A Menu Item", KeyEvent.VK_A));
menuBar.add(secondMenu);
frame.setSize(350, 250);
frame.setVisible(true);
-
}
}
< prev index next >