public class BasicArrowButton extends JButton implements SwingConstants
JButton object that draws a scaled Arrow in one of the cardinal directions.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans™ has been added to the java.beans
package. Please see XMLEncoder
.
JButton.AccessibleJButton
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
protected int direction
The direction of the arrow. One of SwingConstants.NORTH
, SwingConstants.SOUTH
, SwingConstants.EAST
or SwingConstants.WEST
.
public BasicArrowButton(int direction, Color background, Color shadow, Color darkShadow, Color highlight)
Creates a BasicArrowButton
whose arrow is drawn in the specified direction and with the specified colors.
direction
- the direction of the arrow; one of SwingConstants.NORTH
, SwingConstants.SOUTH
, SwingConstants.EAST
or SwingConstants.WEST
background
- the background color of the buttonshadow
- the color of the shadowdarkShadow
- the color of the dark shadowhighlight
- the color of the highlightpublic BasicArrowButton(int direction)
Creates a BasicArrowButton
whose arrow is drawn in the specified direction.
direction
- the direction of the arrow; one of SwingConstants.NORTH
, SwingConstants.SOUTH
, SwingConstants.EAST
or SwingConstants.WEST
public int getDirection()
Returns the direction of the arrow.
public void setDirection(int direction)
Sets the direction of the arrow.
direction
- the direction of the arrow; one of of SwingConstants.NORTH
, SwingConstants.SOUTH
, SwingConstants.EAST
or SwingConstants.WEST
public void paint(Graphics g)
Description copied from class: JComponent
Invoked by Swing to draw components. Applications should not invoke paint
directly, but should instead use the repaint
method to schedule the component for redrawing.
This method actually delegates the work of painting to three protected methods: paintComponent
, paintBorder
, and paintChildren
. They're called in the order listed to ensure that children appear on top of component itself. Generally speaking, the component and its children should not paint in the insets area allocated to the border. Subclasses can just override this method, as always. A subclass that just wants to specialize the UI (look and feel) delegate's paint
method should just override paintComponent
.
paint
in class JComponent
g
- the Graphics
context in which to paintJComponent.paintComponent(java.awt.Graphics)
, JComponent.paintBorder(java.awt.Graphics)
, JComponent.paintChildren(java.awt.Graphics)
, JComponent.getComponentGraphics(java.awt.Graphics)
, JComponent.repaint(long, int, int, int, int)
public Dimension getPreferredSize()
Returns the preferred size of the BasicArrowButton
.
getPreferredSize
in class JComponent
JComponent.setPreferredSize(java.awt.Dimension)
, ComponentUI
public Dimension getMinimumSize()
Returns the minimum size of the BasicArrowButton
.
getMinimumSize
in class JComponent
JComponent.setMinimumSize(java.awt.Dimension)
, ComponentUI
public Dimension getMaximumSize()
Returns the maximum size of the BasicArrowButton
.
getMaximumSize
in class JComponent
JComponent.setMaximumSize(java.awt.Dimension)
, ComponentUI
public boolean isFocusTraversable()
Returns whether the arrow button should get the focus. BasicArrowButton
s are used as a child component of composite components such as JScrollBar
and JComboBox
. Since the composite component typically gets the focus, this method is overriden to return false
.
isFocusTraversable
in class Component
false
Component.setFocusable(boolean)
public void paintTriangle(Graphics g, int x, int y, int size, int direction, boolean isEnabled)
Paints a triangle.
g
- the Graphics
to draw tox
- the x coordinatey
- the y coordinatesize
- the size of the triangle to drawdirection
- the direction in which to draw the arrow; one of SwingConstants.NORTH
, SwingConstants.SOUTH
, SwingConstants.EAST
or SwingConstants.WEST
isEnabled
- whether or not the arrow is drawn enabled
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.