HI,

I fixed a little issue in the button UIs. They used to fill the
background for pressed buttons even if they are opaque. This is of
course wrong.

2005-10-25  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/plaf/basic/BasicButtonUI.java
        (installDefaults): Removed initialization of unnecessary
focusColor
        field.
        (paintButtonPressed): Only paint if button is opaque.
        * javax/swing/plaf/metal/MetalButtonUI.java
        (paintButtonPressed): Only paint if button is opaque and
        contentAreaFilled.

/Roman
Index: javax/swing/plaf/basic/BasicButtonUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicButtonUI.java,v
retrieving revision 1.31
diff -u -r1.31 BasicButtonUI.java
--- javax/swing/plaf/basic/BasicButtonUI.java	12 Oct 2005 12:09:59 -0000	1.31
+++ javax/swing/plaf/basic/BasicButtonUI.java	25 Oct 2005 19:53:06 -0000
@@ -38,7 +38,6 @@
 
 package javax.swing.plaf.basic;
 
-import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.FontMetrics;
@@ -78,8 +77,6 @@
 
   private int textShiftOffset;
 
-  private Color focusColor;
-
   /**
    * Factory method to create an instance of BasicButtonUI for a given
    * [EMAIL PROTECTED] JComponent}, which should be an [EMAIL PROTECTED] AbstractButton}.
@@ -160,7 +157,6 @@
     LookAndFeel.installColorsAndFont(b, prefix + "background",
                                      prefix + "foreground", prefix + "font");
     LookAndFeel.installBorder(b, prefix + "border");
-    focusColor = UIManager.getColor(prefix + "focus");
     b.setMargin(UIManager.getInsets(prefix + "margin"));
     b.setIconTextGap(UIManager.getInt(prefix + "textIconGap"));
     b.setInputMap(JComponent.WHEN_FOCUSED, 
@@ -401,11 +397,11 @@
    */
   protected void paintButtonPressed(Graphics g, AbstractButton b)
   {
-    if (b.isContentAreaFilled())
+    if (b.isContentAreaFilled() && b.isOpaque())
       {
-	Rectangle area = new Rectangle();
-	SwingUtilities.calculateInnerArea(b, area);
-        g.setColor(b.getBackground().darker());
+        Rectangle area = new Rectangle();
+        SwingUtilities.calculateInnerArea(b, area);
+        g.setColor(UIManager.getColor(getPropertyPrefix() + "shadow"));
         g.fillRect(area.x, area.y, area.width, area.height);
       }
   }
Index: javax/swing/plaf/metal/MetalToggleButtonUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java,v
retrieving revision 1.4
diff -u -r1.4 MetalToggleButtonUI.java
--- javax/swing/plaf/metal/MetalToggleButtonUI.java	15 Sep 2005 13:19:10 -0000	1.4
+++ javax/swing/plaf/metal/MetalToggleButtonUI.java	25 Oct 2005 19:53:06 -0000
@@ -144,11 +144,14 @@
    */
   protected void paintButtonPressed(Graphics g, AbstractButton b)
   {
-    Color saved = g.getColor();
-    Rectangle bounds = SwingUtilities.getLocalBounds(b);
-    g.setColor(selectColor);
-    g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
-    g.setColor(saved);
+    if (b.isContentAreaFilled() && b.isOpaque())
+      {
+        Color saved = g.getColor();
+        Rectangle bounds = SwingUtilities.getLocalBounds(b);
+        g.setColor(selectColor);
+        g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
+        g.setColor(saved);
+      }
   }
   
   /**
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to