changeset 5226:05c69338ee73

7169111: Unreadable menu bar with Ambiance theme in GTK L&F Reviewed-by: kizune
author rupashka
date Thu, 12 Jul 2012 14:47:13 +0400
parents 0039f5c7fb51
children a51e0bc5a081
files src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyleFactory.java src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java
diffstat 3 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java	Wed Jul 11 16:19:41 2012 -0700
+++ b/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java	Thu Jul 12 14:47:13 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/src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyleFactory.java	Wed Jul 11 16:19:41 2012 -0700
+++ b/src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyleFactory.java	Thu Jul 12 14:47:13 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/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java	Wed Jul 11 16:19:41 2012 -0700
+++ b/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java	Thu Jul 12 14:47:13 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());
         }
     }