< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java

Print this page
rev 47462 : Fixed JDK-8178430: JMenu in GridBagLayout flickers when label text shows "..."
and is updated.
***
JDK-8178430: Fixed following issues with the test:
1. Throw exception in case the menu bar size is not proper.
2. Run the test for about 10 seconds, and then automatically
close the window.

@@ -457,11 +457,15 @@
         Dimension d = null;
         View v = (View) c.getClientProperty(BasicHTML.propertyKey);
         if (v != null) {
             d = getPreferredSize(c);
             d.width -= v.getPreferredSpan(View.X_AXIS) - v.getMinimumSpan(View.X_AXIS);
+        } else if (c.getParent() instanceof JMenuBar) {
+            //if the menu is a toplevel item, then return preferred size.
+            d = getPreferredSize(c);
         }
+
         return d;
     }
 
     public Dimension getPreferredSize(JComponent c) {
         return getPreferredMenuItemSize(c,
< prev index next >