javax.swing.plaf.basic
Class BasicArrowButton

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.AbstractButton
                  extended by javax.swing.JButton
                      extended by javax.swing.plaf.basic.BasicArrowButton
All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants
Direct Known Subclasses:
MetalScrollButton

public class BasicArrowButton
extends JButton
implements SwingConstants

A button that displays an arrow (triangle) that points SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST or SwingConstants.WEST. This button is used by the BasicComboBoxUI class.

See Also:
BasicComboBoxUI.createArrowButton(), Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JButton
JButton.AccessibleJButton
 
Nested classes/interfaces inherited from class javax.swing.AbstractButton
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  int direction
          The direction that the arrow points.
 
Fields inherited from class javax.swing.AbstractButton
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
BasicArrowButton(int direction)
          Creates a new BasicArrowButton object with an arrow pointing in the specified direction.
BasicArrowButton(int direction, Color background, Color shadow, Color darkShadow, Color highlight)
          Creates a new BasicArrowButton object with the given colors and direction.
 
Method Summary
 int getDirection()
          Returns the direction of the arrow (one of: SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST and SwingConstants.WEST).
 Dimension getMaximumSize()
          Returns the maximum size of the arrow button.
 Dimension getMinimumSize()
          Returns the minimum size of the arrow button.
 Dimension getPreferredSize()
          Returns the preferred size of the arrow button.
 boolean isFocusTraversable()
          Returns whether the focus can traverse to this component.
 void paint(Graphics g)
          Paints the arrow button.
 void paintTriangle(Graphics g, int x, int y, int size, int direction, boolean isEnabled)
          Paints a triangle with the given size, location and direction.
 void setDirection(int dir)
          Sets the direction of the arrow.
 
Methods inherited from class javax.swing.JButton
configurePropertiesFromAction, getAccessibleContext, getUIClassID, isDefaultButton, isDefaultCapable, paramString, removeNotify, setDefaultCapable, updateUI
 
Methods inherited from class javax.swing.AbstractButton
addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, init, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, removeItemListener, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setEnabled, setFocusPainted, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

direction

protected int direction
The direction that the arrow points.

See Also:
getDirection()
Constructor Detail

BasicArrowButton

public BasicArrowButton(int direction)
Creates a new BasicArrowButton object with an arrow pointing in the specified direction. If the direction is not one of the specified constants, no arrow is drawn.

Parameters:
direction - The direction the arrow points in (one of: SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST and SwingConstants.WEST).

BasicArrowButton

public BasicArrowButton(int direction,
                        Color background,
                        Color shadow,
                        Color darkShadow,
                        Color highlight)
Creates a new BasicArrowButton object with the given colors and direction.

Parameters:
direction - The direction to point in (one of: SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST and SwingConstants.WEST).
background - The background color.
shadow - The shadow color.
darkShadow - The dark shadow color.
highlight - The highlight color.
Method Detail

isFocusTraversable

public boolean isFocusTraversable()
Returns whether the focus can traverse to this component. This method always returns false.

Overrides:
isFocusTraversable in class Component
Returns:
false.
See Also:
Component.setFocusable(boolean)

getDirection

public int getDirection()
Returns the direction of the arrow (one of: SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST and SwingConstants.WEST).

Returns:
The direction of the arrow.

setDirection

public void setDirection(int dir)
Sets the direction of the arrow.

Parameters:
dir - The new direction of the arrow (one of: SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST and SwingConstants.WEST).

paint

public void paint(Graphics g)
Paints the arrow button. The painting is delegated to the paintTriangle method.

Overrides:
paint in class JComponent
Parameters:
g - The Graphics object to paint with.
See Also:
JComponent.paintImmediately(Rectangle)

getPreferredSize

public Dimension getPreferredSize()
Returns the preferred size of the arrow button.

Overrides:
getPreferredSize in class JComponent
Returns:
The preferred size (always 16 x 16).
See Also:
Component.setPreferredSize(java.awt.Dimension), Component.getPreferredSize(), Component.isPreferredSizeSet(), ComponentUI.getPreferredSize(JComponent)

getMinimumSize

public Dimension getMinimumSize()
Returns the minimum size of the arrow button.

Overrides:
getMinimumSize in class JComponent
Returns:
The minimum size (always 5 x 5).
See Also:
Component.setMinimumSize(java.awt.Dimension), Component.getMinimumSize(), Component.isMinimumSizeSet(), ComponentUI.getMinimumSize(JComponent)

getMaximumSize

public Dimension getMaximumSize()
Returns the maximum size of the arrow button.

Overrides:
getMaximumSize in class JComponent
Returns:
The maximum size (always Integer.MAX_VALUE x Integer.MAX_VALUE).
See Also:
Component.setMaximumSize(java.awt.Dimension), Component.getMaximumSize(), Component.isMaximumSizeSet(), ComponentUI.getMaximumSize(JComponent)

paintTriangle

public void paintTriangle(Graphics g,
                          int x,
                          int y,
                          int size,
                          int direction,
                          boolean isEnabled)
Paints a triangle with the given size, location and direction. It is difficult to explain the rationale behind the positioning of the triangle relative to the given (x, y) position - by trial and error we seem to match the behaviour of the reference implementation (which is missing a specification for this method).

Parameters:
g - the graphics device.
x - the x-coordinate for the triangle's location.
y - the y-coordinate for the triangle's location.
size - the arrow size (depth).
direction - the direction of the arrow (one of: SwingConstants.NORTH, SwingConstants.SOUTH, SwingConstants.EAST and SwingConstants.WEST).
isEnabled - if true the arrow is drawn in the enabled state, otherwise it is drawn in the disabled state.