This patch fixes the problem where sub-menus were being sized
incorrectly (not respecting the largest element in the popup menu).

Patch attached.

2005-07-18  Anthony Balkissoon  <[EMAIL PROTECTED]>

* javax/swing/plaf/basic/BasicMenuUI.java:
(getMaximumSize): Added check for this menu not being a top level menu.
If that's the case, return the maximum size as if it were a regular
JMenuItem.

-Tony
Index: javax/swing/plaf/basic/BasicMenuUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicMenuUI.java,v
retrieving revision 1.12
diff -u -r1.12 BasicMenuUI.java
--- javax/swing/plaf/basic/BasicMenuUI.java	11 Jul 2005 19:15:27 -0000	1.12
+++ javax/swing/plaf/basic/BasicMenuUI.java	18 Jul 2005 18:52:18 -0000
@@ -46,6 +46,7 @@
 import javax.swing.JComponent;
 import javax.swing.JMenu;
 import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
 import javax.swing.JPopupMenu;
 import javax.swing.MenuSelectionManager;
 import javax.swing.UIDefaults;
@@ -179,6 +180,12 @@
    */
   public Dimension getMaximumSize(JComponent c)
   {
+    // If this menu is in a popup menu, treat it like a regular JMenuItem
+    if (!((JMenu)c).isTopLevelMenu())
+      {
+        JMenuItem menuItem = new JMenuItem(((JMenu)c).getText(), ((JMenu)c).getIcon());
+        return menuItem.getMaximumSize();
+      }
     return c.getPreferredSize();
   }
 
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to