This fixes bug 24651. The menu's width was being increased each time it
was opened. This is now fixed.
2005-11-07 Lillian Angel <[EMAIL PROTECTED]>
* javax/swing/plaf/basic/BasicMenuItemUI.java
(getPreferredMenuItemSize): Adjusted width of menu item with
arrow icon. If the menu item can fit in the current width of
the top level menu, then the width of the menu item is set to
the width of the popup menu. Otherwise, the width of the
menu item is adjusted so that the width of the popup menu
is increased.
Index: javax/swing/plaf/basic/BasicMenuItemUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java,v
retrieving revision 1.35
diff -u -r1.35 BasicMenuItemUI.java
--- javax/swing/plaf/basic/BasicMenuItemUI.java 4 Nov 2005 18:47:45 -0000 1.35
+++ javax/swing/plaf/basic/BasicMenuItemUI.java 7 Nov 2005 14:40:35 -0000
@@ -342,21 +342,22 @@
if (checkIcon != null)
{
- d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap;
+ d.width += checkIcon.getIconWidth() + defaultTextIconGap;
if (checkIcon.getIconHeight() > d.height)
d.height = checkIcon.getIconHeight();
}
if (arrowIcon != null && (c instanceof JMenu))
- {
- if (!((JMenu) c).isTopLevelMenu())
- // It is a MenuItem
- d.width += arrowIcon.getIconWidth() + m.getParent().getWidth();
+ {
+ int pWidth = m.getParent().getWidth();
+ // Check if MenuItem fits in PopupMenu, otherwise
+ // increase the width of the MenuItem
+ if (!((JMenu)c).isTopLevelMenu() && d.width < pWidth)
+ d.width = pWidth;
else
- // It is a Menu, no arrowIcon painted.
- d.width += MenuGap;
-
+ d.width += arrowIcon.getIconWidth() + MenuGap;
+
if (arrowIcon.getIconHeight() > d.height)
d.height = arrowIcon.getIconHeight();
}
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches