Fixes Bug #24651

2005-11-03  Lillian Angel  <[EMAIL PROTECTED]>

        * javax/swing/plaf/basic/BasicMenuItemUI.java:
        Changed field to be the gap between the different
        menu's instead. defaultTextArrowGap is not needed.
        (getPreferredMenuItemSize): Adjusted preferred size of
        Menu Item with an arrowIcon to be the size of the
        popupMenu. If its parent is not a popupMenu, then
        it is a new Menu on a MenuBar.
        * javax/swing/plaf/metal/MetalButtonUI.java
        (paintFocus): Height of focus border should not be
        adjusted. It was being cutoff.

Index: javax/swing/plaf/basic/BasicMenuItemUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java,v
retrieving revision 1.33
diff -u -r1.33 BasicMenuItemUI.java
--- javax/swing/plaf/basic/BasicMenuItemUI.java	1 Nov 2005 15:39:41 -0000	1.33
+++ javax/swing/plaf/basic/BasicMenuItemUI.java	3 Nov 2005 16:09:53 -0000
@@ -169,9 +169,9 @@
   private int defaultAcceleratorLabelGap = 10;
 
   /**
-   * Number of spaces between the text and the arrow icon.
+   * The gap between different menus on the MenuBar.
    */
-  private int defaultTextArrowIconGap = 10;
+  private int MenuGap = 10;
   
   /**
    * Creates a new BasicMenuItemUI object.
@@ -350,7 +350,13 @@
 
     if (arrowIcon != null && (c instanceof JMenu))
       {
-        d.width = d.width + arrowIcon.getIconWidth() + defaultTextArrowIconGap;
+        Component parent = m.getParent();
+        if (parent instanceof JPopupMenu)
+          // It is a MenuItem
+          d.width += arrowIcon.getIconWidth() + parent.getWidth();
+        else
+          // It is a Menu, no arrowIcon painted.
+          d.width += MenuGap;
 
         if (arrowIcon.getIconHeight() > d.height)
           d.height = arrowIcon.getIconHeight();
@@ -520,7 +526,7 @@
     int horAlign = m.getHorizontalAlignment();
     int vertTextPos = m.getVerticalTextPosition();
     int horTextPos = m.getHorizontalTextPosition();
-
+    
     Font f = m.getFont();
     g.setFont(f);
     FontMetrics fm = g.getFontMetrics(f);
Index: javax/swing/plaf/metal/MetalButtonUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalButtonUI.java,v
retrieving revision 1.8
diff -u -r1.8 MetalButtonUI.java
--- javax/swing/plaf/metal/MetalButtonUI.java	27 Oct 2005 09:50:58 -0000	1.8
+++ javax/swing/plaf/metal/MetalButtonUI.java	3 Nov 2005 16:09:54 -0000
@@ -197,8 +197,8 @@
       Color savedColor = g.getColor();
       g.setColor(getFocusColor());
       Rectangle focusRect = iconRect.union(textRect);
-      g.drawRect(focusRect.x - 1, focusRect.y - 1,
-                 focusRect.width + 1, focusRect.height + 1);
+      g.drawRect(focusRect.x - 1, focusRect.y,
+                 focusRect.width + 1, focusRect.height);
       g.setColor(savedColor);
     }
   }
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to