Top Description Fields Constructors Methods
javax.swing.plaf.basic

public Class BasicArrowButton

extends JButton
implements SwingConstants
Class Inheritance
All Implemented Interfaces
javax.swing.SwingConstants
Known Direct Subclasses
javax.swing.plaf.basic.BasicTabbedPaneUI.ScrollableTabButton, javax.swing.plaf.metal.MetalScrollButton, com.sun.java.swing.plaf.motif.MotifScrollBarButton, sun.awt.X11.XTextAreaPeer.XAWTScrollBarButton
Annotations
@SuppressWarnings:serial
Imports
java.awt.Dimension, .Graphics, .Color, .Graphics2D, java.awt.geom.AffineTransform, .Path2D, javax.swing.*, javax.swing.plaf.UIResource, sun.swing.SwingUtilities2

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 java.beans.XMLEncoder.

Author
David Kloba

Field Summary

Modifier and TypeField and Description
private Color
protected int
direction

The direction of the arrow.

private Color
private Color

Constructor Summary

AccessConstructor and Description
public
BasicArrowButton(int
the direction of the arrow; one of SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST or SwingConstants.WEST
direction
,
Color
the background color of the button
background
,
Color
the color of the shadow
shadow
,
Color
the color of the dark shadow
darkShadow
,
Color
the color of the highlight
highlight
)

Creates a BasicArrowButton whose arrow is drawn in the specified direction and with the specified colors.

public
BasicArrowButton(int
the direction of the arrow; one of SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST or SwingConstants.WEST
direction
)

Creates a BasicArrowButton whose arrow is drawn in the specified direction.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the direction of the arrow
getDirection
()

Returns the direction of the arrow.

public Dimension

Returns:

the maximum size
getMaximumSize
()

Overrides javax.swing.JComponent.getMaximumSize.

Returns the maximum size of the BasicArrowButton.
public Dimension

Returns:

the minimum size
getMinimumSize
()

Overrides javax.swing.JComponent.getMinimumSize.

Returns the minimum size of the BasicArrowButton.
public Dimension

Returns:

the preferred size
getPreferredSize
()

Overrides javax.swing.JComponent.getPreferredSize.

Returns the preferred size of the BasicArrowButton.
public boolean

Returns:

false
isFocusTraversable
()

Overrides java.awt.Component.isFocusTraversable.

Returns whether the arrow button should get the focus.
public void
paint(Graphics
the Graphics context in which to paint
g
)

Overrides javax.swing.JComponent.paint.

Invoked by Swing to draw components.
private void
paintScaledTriangle(Graphics g, double x, double y, double size, int direction, boolean isEnabled)

public void
paintTriangle(Graphics
the Graphics to draw to
g
,
int
the x coordinate
x
,
int
the y coordinate
y
,
int
the size of the triangle to draw
size
,
int
the direction in which to draw the arrow; one of SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST or SwingConstants.WEST
direction
,
boolean
whether or not the arrow is drawn enabled
isEnabled
)

Paints a triangle.

private void
paintUnscaledTriangle(Graphics g, int x, int y, int size, int direction, boolean isEnabled)

public void
setDirection(int
the direction of the arrow; one of of SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST or SwingConstants.WEST
direction
)

Sets the direction of the arrow.

Inherited from javax.swing.JButton:
getAccessibleContextgetUIClassIDisDefaultButtonisDefaultCapableparamStringremoveNotifysetDefaultCapableupdateUI

Field Detail

darkShadowback to summary
private Color darkShadow
directionback to summary
protected int direction

The direction of the arrow. One of SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST or SwingConstants.WEST.

highlightback to summary
private Color highlight
shadowback to summary
private Color shadow

Constructor Detail

BasicArrowButtonback to summary
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.

Parameters
direction:int

the direction of the arrow; one of SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST or SwingConstants.WEST

background:Color

the background color of the button

shadow:Color

the color of the shadow

darkShadow:Color

the color of the dark shadow

highlight:Color

the color of the highlight

Since
1.4
BasicArrowButtonback to summary
public BasicArrowButton(int direction)

Creates a BasicArrowButton whose arrow is drawn in the specified direction.

Parameters
direction:int

the direction of the arrow; one of SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST or SwingConstants.WEST

Method Detail

getDirectionback to summary
public int getDirection()

Returns the direction of the arrow.

Returns:int

the direction of the arrow

getMaximumSizeback to summary
public Dimension getMaximumSize()

Overrides javax.swing.JComponent.getMaximumSize.

Returns the maximum size of the BasicArrowButton.

Returns:Dimension

the maximum size

getMinimumSizeback to summary
public Dimension getMinimumSize()

Overrides javax.swing.JComponent.getMinimumSize.

Returns the minimum size of the BasicArrowButton.

Returns:Dimension

the minimum size

getPreferredSizeback to summary
public Dimension getPreferredSize()

Overrides javax.swing.JComponent.getPreferredSize.

Returns the preferred size of the BasicArrowButton.

Returns:Dimension

the preferred size

isFocusTraversableback to summary
public boolean isFocusTraversable()

Overrides java.awt.Component.isFocusTraversable.

Returns whether the arrow button should get the focus. BasicArrowButtons 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 overridden to return false.

Returns:boolean

false

Annotations
@SuppressWarnings:deprecation
paintback to summary
public void paint(Graphics g)

Overrides javax.swing.JComponent.paint.

Doc from javax.swing.JComponent.paint.

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.

Parameters
g:Graphics

the Graphics context in which to paint

paintScaledTriangleback to summary
private void paintScaledTriangle(Graphics g, double x, double y, double size, int direction, boolean isEnabled)
paintTriangleback to summary
public void paintTriangle(Graphics g, int x, int y, int size, int direction, boolean isEnabled)

Paints a triangle.

Parameters
g:Graphics

the Graphics to draw to

x:int

the x coordinate

y:int

the y coordinate

size:int

the size of the triangle to draw

direction:int

the direction in which to draw the arrow; one of SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST or SwingConstants.WEST

isEnabled:boolean

whether or not the arrow is drawn enabled

paintUnscaledTriangleback to summary
private void paintUnscaledTriangle(Graphics g, int x, int y, int size, int direction, boolean isEnabled)
setDirectionback to summary
public void setDirection(int direction)

Sets the direction of the arrow.

Parameters
direction:int

the direction of the arrow; one of of SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST or SwingConstants.WEST