7169111: Unreadable menu bar with Ambiance theme in GTK L&F
authorrupashka
Thu, 28 Jun 2012 14:05:06 +0400
changeset 13147 eada40c7d74d
parent 13146 6248ba961deb
child 13148 578ac31dc2f9
child 13233 4d45f7ebc0d7
7169111: Unreadable menu bar with Ambiance theme in GTK L&F Reviewed-by: kizune
jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java
jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyleFactory.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java	Wed Jun 27 12:54:48 2012 -0700
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java	Thu Jun 28 14:05:06 2012 +0400
@@ -796,9 +796,10 @@
             "Menu.margin", zeroInsets,
             "Menu.cancelMode", "hideMenuTree",
             "Menu.alignAcceleratorText", Boolean.FALSE,
+            "Menu.useMenuBarForTopLevelMenus", Boolean.TRUE,
 
 
-            "MenuBar.windowBindings", new Object[] {
+                "MenuBar.windowBindings", new Object[] {
                 "F10", "takeFocus" },
             "MenuBar.font", new FontLazyValue(Region.MENU_BAR),
 
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyleFactory.java	Wed Jun 27 12:54:48 2012 -0700
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyleFactory.java	Thu Jun 28 14:05:06 2012 +0400
@@ -92,7 +92,13 @@
                 boolean defaultCapable = btn.isDefaultCapable();
                 key = new ComplexKey(wt, toolButton, defaultCapable);
             }
+        } else if (id == Region.MENU) {
+            if (c instanceof JMenu && ((JMenu) c).isTopLevelMenu() &&
+                    UIManager.getBoolean("Menu.useMenuBarForTopLevelMenus")) {
+                wt = WidgetType.MENU_BAR;
+            }
         }
+
         if (key == null) {
             // Otherwise, just use the WidgetType as the key.
             key = wt;
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java	Wed Jun 27 12:54:48 2012 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java	Thu Jun 28 14:05:06 2012 +0400
@@ -299,7 +299,8 @@
      */
     @Override
     public void propertyChange(PropertyChangeEvent e) {
-        if (SynthLookAndFeel.shouldUpdateStyle(e)) {
+        if (SynthLookAndFeel.shouldUpdateStyle(e) ||
+                (e.getPropertyName().equals("ancestor") && UIManager.getBoolean("Menu.useMenuBarForTopLevelMenus"))) {
             updateStyle((JMenu)e.getSource());
         }
     }