8003978: closed/javax/swing/JRootPane/bug4670486.java fails since jdk7u12b01 on macosx
authoralexsch
Tue, 15 Jan 2013 12:49:03 +0400
changeset 15316 0dcb6f02678d
parent 15315 9db01c15ae0c
child 15317 a5c7745e4127
8003978: closed/javax/swing/JRootPane/bug4670486.java fails since jdk7u12b01 on macosx Reviewed-by: serb, leonidr
jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java
jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java
jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java
jdk/src/share/classes/sun/swing/SwingUtilities2.java
jdk/test/java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.java
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java	Mon Jan 14 08:32:29 2013 -0500
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java	Tue Jan 15 12:49:03 2013 +0400
@@ -787,7 +787,6 @@
             "List.font", new FontLazyValue(Region.LIST),
             "List.rendererUseUIBorder", Boolean.FALSE,
 
-            "Menu.shortcutKeys", new int[] {KeyEvent.ALT_MASK},
             "Menu.arrowIcon", new GTKStyle.GTKLazyValue(
                               "com.sun.java.swing.plaf.gtk.GTKIconFactory",
                               "getMenuArrowIcon"),
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java	Mon Jan 14 08:32:29 2013 -0500
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java	Tue Jan 15 12:49:03 2013 +0400
@@ -630,8 +630,10 @@
             "Menu.menuPopupOffsetY", new Integer(0),
             "Menu.submenuPopupOffsetX", new Integer(-2),
             "Menu.submenuPopupOffsetY", new Integer(3),
-            "Menu.shortcutKeys", new int[] {KeyEvent.ALT_MASK,
-                                            KeyEvent.META_MASK},
+            "Menu.shortcutKeys", new int[]{
+                SwingUtilities2.getSystemMnemonicKeyMask(),
+                KeyEvent.META_MASK
+            },
             "Menu.cancelMode", "hideMenuTree",
 
             "MenuBar.border", menuBarBorder,
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java	Mon Jan 14 08:32:29 2013 -0500
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java	Tue Jan 15 12:49:03 2013 +0400
@@ -1153,7 +1153,9 @@
             "Menu.menuPopupOffsetY", new Integer(0),
             "Menu.submenuPopupOffsetX", new Integer(0),
             "Menu.submenuPopupOffsetY", new Integer(0),
-            "Menu.shortcutKeys", new int[] {KeyEvent.ALT_MASK},
+            "Menu.shortcutKeys", new int[]{
+                SwingUtilities2.getSystemMnemonicKeyMask()
+            },
             "Menu.crossMenuMnemonic", Boolean.TRUE,
             // Menu.cancelMode affects the cancel menu action behaviour;
             // currently supports:
--- a/jdk/src/share/classes/sun/swing/SwingUtilities2.java	Mon Jan 14 08:32:29 2013 -0500
+++ b/jdk/src/share/classes/sun/swing/SwingUtilities2.java	Tue Jan 15 12:49:03 2013 +0400
@@ -1879,4 +1879,12 @@
         }
         return -1;
     }
+
+    public static int getSystemMnemonicKeyMask() {
+        Toolkit toolkit = Toolkit.getDefaultToolkit();
+        if (toolkit instanceof SunToolkit) {
+            return ((SunToolkit) toolkit).getFocusAcceleratorKeyMask();
+        }
+        return InputEvent.ALT_MASK;
+    }
 }
--- a/jdk/test/java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.java	Mon Jan 14 08:32:29 2013 -0500
+++ b/jdk/test/java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.java	Tue Jan 15 12:49:03 2013 +0400
@@ -36,6 +36,7 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.lang.reflect.InvocationTargetException;
 import test.java.awt.regtesthelpers.Util;
+import sun.awt.OSInfo;
 
 public class SubMenuShowTest extends Applet {
     Robot robot;
@@ -86,6 +87,11 @@
         frame.setVisible(true);
         Util.waitForIdle(robot);
 
+        boolean isMacOSX = (OSInfo.getOSType() == OSInfo.OSType.MACOSX);
+        if (isMacOSX) {
+            robot.keyPress(KeyEvent.VK_CONTROL);
+            robot.delay(20);
+        }
         robot.keyPress(KeyEvent.VK_ALT);
         robot.delay(20);
         robot.keyPress(KeyEvent.VK_F);
@@ -93,6 +99,10 @@
         robot.keyRelease(KeyEvent.VK_F);
         robot.delay(20);
         robot.keyRelease(KeyEvent.VK_ALT);
+        if (isMacOSX) {
+            robot.keyRelease(KeyEvent.VK_CONTROL);
+            robot.delay(20);
+        }
         Util.waitForIdle(robot);
 
         robot.keyPress(KeyEvent.VK_M);