classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: MetalBorders.RolloverButtonBorder


From: David Gilbert
Subject: [cp-patches] FYI: MetalBorders.RolloverButtonBorder
Date: Tue, 27 Sep 2005 21:55:48 +0000
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050728)

I committed this patch to add another missing border:

2005-09-27  David Gilbert  <address@hidden>

        * javax/swing/plaf/metal/MetalBorders.java
        (RolloverButtonBorder): new class.

Regards,

Dave
Index: javax/swing/plaf/metal/MetalBorders.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalBorders.java,v
retrieving revision 1.20
diff -u -r1.20 MetalBorders.java
--- javax/swing/plaf/metal/MetalBorders.java    27 Sep 2005 15:40:26 -0000      
1.20
+++ javax/swing/plaf/metal/MetalBorders.java    27 Sep 2005 20:51:04 -0000
@@ -918,6 +918,44 @@
   }
   
   /**
+   * A button border that is only visible when the mouse pointer is within 
+   * the button's bounds.
+   */
+  public static class RolloverButtonBorder
+    extends MetalBorders.ButtonBorder
+  {
+    /**
+     * Creates a new border instance.
+     */
+    public RolloverButtonBorder()
+    {
+    }
+    
+    /**
+     * Paints the border.
+     * 
+     * @param c  the component.
+     * @param g  the graphics device.
+     * @param x  the x-coordinate.
+     * @param y  the y-coordinate.
+     * @param w  the width.
+     * @param h  the height.
+     */
+    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);
+    }
+  }
+  
+  /**
    * This border is used in Toolbar buttons as inner border.
    */
   static class RolloverMarginBorder extends AbstractBorder

reply via email to

[Prev in Thread] Current Thread [Next in Thread]