This fixes some smaller stuff in the MetalL&F. There are some stange
things in the MetalL&F, like there is a class
MetalBorders.RolloverButtonBorder, but apparently in Sun's
implementation this is not used at all. If a button is set to
rolloverEnabled (either directly or via a UI property), the border
remains the same (MetalBorders.ButtonBorder). This means (to me), that
the ButtonBorder already handles the rolloverEnabled state and the
RolloverButtonBorder only forwards to super. The same is in the
MetalButtonListener.

There's some other very minor glitches I found and fixed along the way:

2006-03-10  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/plaf/metal/MetalBorders.java
        (RolloverButtonBorder.paintBorder): Only call super here.
        * javax/swing/plaf/metal/MetalButtonListener.java
        (propertyChange): Only call super here.
        * javax/swing/plaf/metal/MetalButtonUI.java
        (update): Changed condition from isOpaque() to
isContentAreaFilled()
        for the gradient fill.
        * javax/swing/plaf/metal/MetalToggleButtonUI.java
        (paintText): API doc fix. Makes paintText not deprecated as
specified
        but adds comment that this is obsolete.
        * javax/swing/plaf/metal/MetalUtils.java
        (fillMetalPattern): Fixed condition so that the Java2D is not
        used when the noGraphics2D property is set.

/Roman
Index: javax/swing/plaf/metal/MetalBorders.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalBorders.java,v
retrieving revision 1.30
diff -u -r1.30 MetalBorders.java
--- javax/swing/plaf/metal/MetalBorders.java	13 Feb 2006 14:04:05 -0000	1.30
+++ javax/swing/plaf/metal/MetalBorders.java	10 Mar 2006 22:40:15 -0000
@@ -1025,14 +1025,10 @@
     public void paintBorder(Component c, Graphics g, int x, int y, int w, 
             int h)
     {
-      boolean mouseIsOver = false;
-      if (c instanceof AbstractButton)
-        {
-          ButtonModel bmodel = ((AbstractButton) c).getModel();
-          mouseIsOver = bmodel.isRollover();
-        }
-      if (mouseIsOver)
-        super.paintBorder(c, g, x, y, w, h);
+      // TODO: What should be done here? Obviously the ButtonBorder already
+      // handles the rollover state in Sun's impl. Maybe this is only there
+      // for backwards compatibility.
+      super.paintBorder(c, g, x, y, w, h);
     }
   }
   
Index: javax/swing/plaf/metal/MetalButtonListener.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalButtonListener.java,v
retrieving revision 1.3
diff -u -r1.3 MetalButtonListener.java
--- javax/swing/plaf/metal/MetalButtonListener.java	19 Oct 2005 13:46:02 -0000	1.3
+++ javax/swing/plaf/metal/MetalButtonListener.java	10 Mar 2006 22:40:15 -0000
@@ -41,7 +41,6 @@
 import java.beans.PropertyChangeEvent;
 
 import javax.swing.AbstractButton;
-import javax.swing.plaf.UIResource;
 import javax.swing.plaf.basic.BasicButtonListener;
 
 /**
@@ -70,17 +69,6 @@
   public void propertyChange(PropertyChangeEvent e)
   {
     super.propertyChange(e);
-    if (e.getPropertyName().equals(
-            AbstractButton.ROLLOVER_ENABLED_CHANGED_PROPERTY))
-      {
-        AbstractButton b = (AbstractButton) e.getSource();
-        if (b.getBorder() instanceof UIResource)
-          {
-            if (Boolean.TRUE.equals(e.getNewValue()))
-              b.setBorder(MetalBorders.getRolloverBorder());
-            else if (Boolean.FALSE.equals(e.getNewValue()))
-              b.setBorder(MetalBorders.getButtonBorder());
-          }
-      }
+    // TODO: What should be done here?
   }
 }
Index: javax/swing/plaf/metal/MetalButtonUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalButtonUI.java,v
retrieving revision 1.13
diff -u -r1.13 MetalButtonUI.java
--- javax/swing/plaf/metal/MetalButtonUI.java	16 Nov 2005 20:33:06 -0000	1.13
+++ javax/swing/plaf/metal/MetalButtonUI.java	10 Mar 2006 22:40:15 -0000
@@ -50,7 +50,6 @@
 import javax.swing.SwingConstants;
 import javax.swing.UIManager;
 import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.UIResource;
 import javax.swing.plaf.basic.BasicButtonListener;
 import javax.swing.plaf.basic.BasicButtonUI;
 
@@ -234,7 +233,8 @@
   public void update(Graphics g, JComponent c)
   {
     AbstractButton b = (AbstractButton) c;
-    if (b.isOpaque() && UIManager.get(getPropertyPrefix() + "gradient") != null
+    if (b.isContentAreaFilled()
+        && UIManager.get(getPropertyPrefix() + "gradient") != null
         && !b.getModel().isPressed() && b.isEnabled())
       {
         MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
Index: javax/swing/plaf/metal/MetalToggleButtonUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java,v
retrieving revision 1.8
diff -u -r1.8 MetalToggleButtonUI.java
--- javax/swing/plaf/metal/MetalToggleButtonUI.java	16 Nov 2005 15:43:34 -0000	1.8
+++ javax/swing/plaf/metal/MetalToggleButtonUI.java	10 Mar 2006 22:40:15 -0000
@@ -157,13 +157,15 @@
   /**
    * Paints the text for the button.
    * 
+   * As of JDK 1.4 this method is obsolete.
+   * Use [EMAIL PROTECTED] BasicButtonUI#paintText(java.awt.Graphics, 
+   * javax.swing.AbstractButton, java.awt.Rectangle, java.lang.String)}.
+   *
    * @param g  the graphics device.
    * @param c  the component.
    * @param textRect  the bounds for the text.
    * @param text  the text.
    * 
-   * @deprecated 1.4 Use [EMAIL PROTECTED] BasicButtonUI#paintText(java.awt.Graphics, 
-   * javax.swing.AbstractButton, java.awt.Rectangle, java.lang.String)}.
    */
   protected void paintText(Graphics g, JComponent c, Rectangle textRect,
                            String text)
Index: javax/swing/plaf/metal/MetalUtils.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalUtils.java,v
retrieving revision 1.8
diff -u -r1.8 MetalUtils.java
--- javax/swing/plaf/metal/MetalUtils.java	3 Mar 2006 11:12:11 -0000	1.8
+++ javax/swing/plaf/metal/MetalUtils.java	10 Mar 2006 22:40:15 -0000
@@ -91,7 +91,7 @@
                                 Color light, Color dark)
   {
     if (g instanceof Graphics2D
-      && SystemProperties.getProperty("gnu.javax.swing.noGraphics2D") != null)
+      && SystemProperties.getProperty("gnu.javax.swing.noGraphics2D") == null)
       fillMetalPattern2D((Graphics2D) g, x, y, w, h, light, dark);
     else
       {

Reply via email to