[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] FYI: BasicArrowButton updates
From: |
David Gilbert |
Subject: |
[cp-patches] FYI: BasicArrowButton updates |
Date: |
Fri, 09 Sep 2005 06:04:59 +0000 |
User-agent: |
Mozilla Thunderbird 1.0.6 (X11/20050728) |
I committed this patch to (a) fix some minor issues with the border painting, and
(b) make the getMaximumSize(), getMinimumSize() and getPreferredSize() methods pass
the Mauve tests I wrote for BasicArrowButton:
2005-09-09 David Gilbert <address@hidden>
* javax/swing/plaf/basic/BasicArrowButton.java
(buttonBorder.paintBorder): fixed drawing issues,
(getMaximumSize): return constant value,
(getMinimumSize): likewise,
(getPreferredSize): likewise.
Regards,
Dave
Index: javax/swing/plaf/basic/BasicArrowButton.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicArrowButton.java,v
retrieving revision 1.12
diff -u -r1.12 BasicArrowButton.java
--- javax/swing/plaf/basic/BasicArrowButton.java 18 Aug 2005 20:22:16
-0000 1.12
+++ javax/swing/plaf/basic/BasicArrowButton.java 9 Sep 2005 04:49:54
-0000
@@ -46,6 +46,7 @@
import java.awt.Polygon;
import java.awt.Rectangle;
+import javax.swing.AbstractButton;
import javax.swing.JButton;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
@@ -113,23 +114,29 @@
public void paintBorder(Component c, Graphics g, int x, int y, int w,
int h)
{
- Color saved = g.getColor();
- g.setColor(highlight);
+ Color saved = g.getColor();
+ AbstractButton b = (AbstractButton) c;
+ if (b.getModel().isPressed())
+ {
+ g.setColor(darkShadow);
+ g.drawRect(x, y, x + w - 1, y + h - 1);
+ }
+ else
+ {
+ g.setColor(highlight);
+ g.drawLine(x + 1, y + 1, x + w - 3, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
+
+ g.setColor(shadow);
+ g.drawLine(x + 1, y + h - 2, x + w - 1, y + h - 2);
+ g.drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2);
+
+ g.setColor(darkShadow);
+ g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
+ g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
- g.drawLine(x + 1, y + 1, x + w - 1, y + 1);
- g.drawLine(x + 1, y + 1, x + 1, y + h - 1);
-
- g.setColor(shadow);
-
- g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
- g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
-
- g.setColor(darkShadow);
-
- g.drawLine(x, y + h, x + w, y + h);
- g.drawLine(x + w, y, x + w, y + h);
-
- g.setColor(saved);
+ g.setColor(saved);
+ }
}
};
@@ -213,6 +220,16 @@
paintTriangle(g, x, y, defaultSize, direction, isEnabled());
}
+ /** The preferred size for the button. */
+ private static final Dimension PREFERRED_SIZE = new Dimension(16, 16);
+
+ /** The minimum size for the button. */
+ private static final Dimension MINIMUM_SIZE = new Dimension(5, 5);
+
+ /** The maximum size for the button. */
+ private static final Dimension MAXIMUM_SIZE
+ = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
+
/**
* This method returns the preferred size of the arrow button.
*
@@ -220,11 +237,7 @@
*/
public Dimension getPreferredSize()
{
- Insets insets = getInsets();
- int w = defaultSize + insets.left + insets.right;
- int h = defaultSize + insets.top + insets.bottom;
-
- return new Dimension(w, h);
+ return PREFERRED_SIZE;
}
/**
@@ -234,7 +247,7 @@
*/
public Dimension getMinimumSize()
{
- return getPreferredSize();
+ return MINIMUM_SIZE;
}
/**
@@ -244,7 +257,7 @@
*/
public Dimension getMaximumSize()
{
- return getPreferredSize();
+ return MAXIMUM_SIZE;
}
/**
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] FYI: BasicArrowButton updates,
David Gilbert <=