summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java')
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java50
1 files changed, 27 insertions, 23 deletions
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java b/libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java
index f796d9a730a..781269b2adf 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java
@@ -1,5 +1,5 @@
/* BasicArrowButton.java --
- Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,7 +42,6 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Polygon;
-import java.awt.Rectangle;
import javax.swing.ButtonModel;
import javax.swing.JButton;
@@ -86,7 +85,9 @@ public class BasicArrowButton extends JButton implements SwingConstants
transient Color highlight = Color.WHITE;
/**
- * Creates a new <code>BasicArrowButton</code> object.
+ * Creates a new <code>BasicArrowButton</code> object with an arrow pointing
+ * in the specified direction. If the <code>direction</code> is not one of
+ * the specified constants, no arrow is drawn.
*
* @param direction The direction the arrow points in (one of:
* {@link #NORTH}, {@link #SOUTH}, {@link #EAST} and {@link #WEST}).
@@ -95,6 +96,7 @@ public class BasicArrowButton extends JButton implements SwingConstants
{
super();
setDirection(direction);
+ setFocusable(false);
}
/**
@@ -116,8 +118,7 @@ public class BasicArrowButton extends JButton implements SwingConstants
this.shadow = shadow;
this.darkShadow = darkShadow;
this.highlight = highlight;
- // Mark the button as not closing the popup, we handle this ourselves.
- putClientProperty(BasicLookAndFeel.DONT_CANCEL_POPUP, Boolean.TRUE);
+ setFocusable(false);
}
/**
@@ -162,28 +163,22 @@ public class BasicArrowButton extends JButton implements SwingConstants
public void paint(Graphics g)
{
super.paint(g);
- Rectangle bounds = getBounds();
- int size = bounds.height / 4;
- int x = bounds.x + (bounds.width - size) / 2;
- int y = (bounds.height - size) / 4;
+
+ int height = getHeight();
+ int size = height / 4;
+
+ int x = (getWidth() - size) / 2;
+ int y = (height - size) / 2;
+
ButtonModel m = getModel();
if (m.isArmed())
{
x++;
y++;
}
+
paintTriangle(g, x, y, size, 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);
/**
* Returns the preferred size of the arrow button.
@@ -192,7 +187,10 @@ public class BasicArrowButton extends JButton implements SwingConstants
*/
public Dimension getPreferredSize()
{
- return PREFERRED_SIZE;
+ // since Dimension is NOT immutable, we must return a new instance
+ // every time (if we return a cached value, the caller might modify it)
+ // - tests show that the reference implementation does the same.
+ return new Dimension(16, 16);
}
/**
@@ -202,17 +200,23 @@ public class BasicArrowButton extends JButton implements SwingConstants
*/
public Dimension getMinimumSize()
{
- return MINIMUM_SIZE;
+ // since Dimension is NOT immutable, we must return a new instance
+ // every time (if we return a cached value, the caller might modify it)
+ // - tests show that the reference implementation does the same.
+ return new Dimension(5, 5);
}
/**
* Returns the maximum size of the arrow button.
*
- * @return The maximum size.
+ * @return The maximum size (always Integer.MAX_VALUE x Integer.MAX_VALUE).
*/
public Dimension getMaximumSize()
{
- return MAXIMUM_SIZE;
+ // since Dimension is NOT immutable, we must return a new instance
+ // every time (if we return a cached value, the caller might modify it)
+ // - tests show that the reference implementation does the same.
+ return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
/**
OpenPOWER on IntegriCloud