org.pushingpixels.flamingo.api.common
Class AbstractCommandButton

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.pushingpixels.flamingo.api.common.RichToolTipManager.JTrackableComponent
                  extended by org.pushingpixels.flamingo.api.common.AbstractCommandButton
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
JCommandButton, JCommandToggleButton

public abstract class AbstractCommandButton
extends RichToolTipManager.JTrackableComponent

Base class for command buttons.

See Also:
Serialized Form

Nested Class Summary
static class AbstractCommandButton.CommandButtonLocationOrderKind
          Enumerates the available values for the location order kind.
 
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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  org.pushingpixels.flamingo.api.common.AbstractCommandButton.ActionHandler actionHandler
          Action handler for the button.
protected  String actionKeyTip
          Key tip for the action area.
protected  ActionButtonModel actionModel
          The button action model.
protected  int customDimension
          The dimension of the icon of the associated command button in the CommandButtonDisplayState.FIT_TO_ICON state.
protected  ResizableIcon disabledIcon
          Associated disabled icon.
protected  CommandButtonDisplayState displayState
          Current display state of this button.
protected  String extraText
          Additional text.
protected  ResizableIcon icon
          Associated icon.
protected  boolean isFlat
          Indication whether this button is flat.
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
AbstractCommandButton(String text, ResizableIcon icon)
          Creates a new command button.
 
Method Summary
 void addActionListener(ActionListener l)
          Adds the specified action listener to this button.
 void addChangeListener(ChangeListener l)
          Adds the specified change listener to this button.
 void doActionClick()
          Programmatically perform an action "click".
protected  void fireActionPerformed(ActionEvent event)
          Notifies all listeners that have registered interest for notification on this event type.
protected  void fireStateChanged()
          Notifies all listeners that have registered interest for notification on this event type.
 String getActionKeyTip()
          Returns the key tip for the action area of this button.
 ActionButtonModel getActionModel()
          Returns the action model for this button.
 int getCustomDimension()
          Returns the dimension of the icon of the associated command button in the CommandButtonDisplayState.FIT_TO_ICON state.
 ResizableIcon getDisabledIcon()
          Returns the associated disabled icon.
 CommandButtonDisplayState getDisplayState()
          Return the current display state of this button.
 String getExtraText()
          Returns the extra text of this button.
 double getHGapScaleFactor()
          Returns the horizontal gap scale factor for the content of this button.
 int getHorizontalAlignment()
          Returns the horizontal alignment for the content of this button.
 ResizableIcon getIcon()
          Returns the associated icon.
 AbstractCommandButton.CommandButtonLocationOrderKind getLocationOrderKind()
          Returns the location order kind for buttons placed in command button strips or for buttons that need the visuals of segmented strips.
 RichTooltip getRichTooltip(MouseEvent mouseEvent)
           
 String getText()
          Returns the text of this button.
 CommandButtonUI getUI()
          Returns the UI delegate for this button.
 double getVGapScaleFactor()
          Returns the vertical gap scale factor for the content of this button.
 boolean isFlat()
          Returns indication whether this button has flat appearance.
 void removeActionListener(ActionListener l)
          Removes the specified action listener from this button.
 void removeChangeListener(ChangeListener l)
          Removes the specified change listener from this button.
 void setActionKeyTip(String actionKeyTip)
          Sets the key tip for the action area of this button.
 void setActionModel(ActionButtonModel newModel)
          Sets the new action model for this button.
 void setActionRichTooltip(RichTooltip richTooltip)
          Sets the rich tooltip for the action area of this button.
 void setDisabledIcon(ResizableIcon disabledIcon)
          Sets the disabled icon for this button.
 void setDisplayState(CommandButtonDisplayState state)
          Sets new display state for this button.
 void setEnabled(boolean b)
           
 void setExtraText(String extraText)
          Sets the extra text for this button.
 void setFlat(boolean isFlat)
          Sets the flat appearance of this button.
 void setGapScaleFactor(double gapScaleFactor)
          Sets new gap scale factor for the content of this button.
 void setHGapScaleFactor(double hgapScaleFactor)
          Sets new horizontal gap scale factor for the content of this button.
 void setHorizontalAlignment(int alignment)
          Sets new horizontal alignment for the content of this button.
 void setIcon(ResizableIcon defaultIcon)
          Sets new icon for this button.
 void setLocationOrderKind(AbstractCommandButton.CommandButtonLocationOrderKind locationOrderKind)
          Sets the location order kind for buttons placed in command button strips or for buttons that need the visuals of segmented strips.
 void setText(String text)
          Sets the new text for this button.
 void setToolTipText(String text)
           
 void setUI(CommandButtonUI ui)
          Sets the new UI delegate.
 void setVGapScaleFactor(double vgapScaleFactor)
          Sets new vertical gap scale factor for the content of this button.
 void updateCustomDimension(int dimension)
          Updates the dimension of the icon of the associated command button in the CommandButtonDisplayState.FIT_TO_ICON state.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, 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, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, 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, 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, setName, 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

icon

protected ResizableIcon icon
Associated icon.

See Also:
setIcon(ResizableIcon), getIcon()

disabledIcon

protected ResizableIcon disabledIcon
Associated disabled icon.

See Also:
setDisabledIcon(ResizableIcon), getDisabledIcon()

actionModel

protected ActionButtonModel actionModel
The button action model.

See Also:
getActionModel(), setActionModel(ActionButtonModel)

extraText

protected String extraText
Additional text. This is shown for CommandButtonDisplayState.TILE .

See Also:
setExtraText(String), getExtraText()

displayState

protected CommandButtonDisplayState displayState
Current display state of this button.

See Also:
setDisplayState(CommandButtonDisplayState), getDisplayState()

customDimension

protected int customDimension
The dimension of the icon of the associated command button in the CommandButtonDisplayState.FIT_TO_ICON state.

See Also:
getCustomDimension(), updateCustomDimension(int)

isFlat

protected boolean isFlat
Indication whether this button is flat.

See Also:
setFlat(boolean), isFlat()

actionHandler

protected org.pushingpixels.flamingo.api.common.AbstractCommandButton.ActionHandler actionHandler
Action handler for the button.


actionKeyTip

protected String actionKeyTip
Key tip for the action area.

See Also:
setActionKeyTip(String), getActionKeyTip()
Constructor Detail

AbstractCommandButton

public AbstractCommandButton(String text,
                             ResizableIcon icon)
Creates a new command button.

Parameters:
text - Button title. May contain any number of words.
icon - Button icon.
Method Detail

setUI

public void setUI(CommandButtonUI ui)
Sets the new UI delegate.

Parameters:
ui - New UI delegate.

getUI

public CommandButtonUI getUI()
Returns the UI delegate for this button.

Returns:
The UI delegate for this button.

setDisplayState

public void setDisplayState(CommandButtonDisplayState state)
Sets new display state for this button. Fires a displayState property change event.

Parameters:
state - New display state.
See Also:
getDisplayState()

getIcon

public ResizableIcon getIcon()
Returns the associated icon.

Returns:
The associated icon.
See Also:
getDisabledIcon(), setIcon(ResizableIcon)

setIcon

public void setIcon(ResizableIcon defaultIcon)
Sets new icon for this button. Fires an icon property change event.

Parameters:
defaultIcon - New default icon for this button.
See Also:
setDisabledIcon(ResizableIcon), getIcon()

setDisabledIcon

public void setDisabledIcon(ResizableIcon disabledIcon)
Sets the disabled icon for this button.

Parameters:
disabledIcon - Disabled icon for this button.
See Also:
setIcon(ResizableIcon), getDisabledIcon()

getDisabledIcon

public ResizableIcon getDisabledIcon()
Returns the associated disabled icon.

Returns:
The associated disabled icon.
See Also:
setDisabledIcon(ResizableIcon), getIcon()

getDisplayState

public CommandButtonDisplayState getDisplayState()
Return the current display state of this button.

Returns:
The current display state of this button.
See Also:
setDisplayState(CommandButtonDisplayState)

getExtraText

public String getExtraText()
Returns the extra text of this button.

Returns:
Extra text of this button.
See Also:
setExtraText(String)

setExtraText

public void setExtraText(String extraText)
Sets the extra text for this button. Fires an extraText property change event.

Parameters:
extraText - Extra text for this button.
See Also:
getExtraText()

getText

public String getText()
Returns the text of this button.

Returns:
The text of this button.
See Also:
setText(String)

setText

public void setText(String text)
Sets the new text for this button. Fires a text property change event.

Parameters:
text - The new text for this button.
See Also:
getText()

updateCustomDimension

public void updateCustomDimension(int dimension)
Updates the dimension of the icon of the associated command button in the CommandButtonDisplayState.FIT_TO_ICON state. Fires a customDimension property change event.

Parameters:
dimension - New dimension of the icon of the associated command button in the CommandButtonDisplayState.FIT_TO_ICON state.
See Also:
getCustomDimension()

getCustomDimension

public int getCustomDimension()
Returns the dimension of the icon of the associated command button in the CommandButtonDisplayState.FIT_TO_ICON state.

Returns:
The dimension of the icon of the associated command button in the CommandButtonDisplayState.FIT_TO_ICON state.
See Also:
updateCustomDimension(int)

isFlat

public boolean isFlat()
Returns indication whether this button has flat appearance.

Returns:
true if this button has flat appearance, false otherwise.
See Also:
setFlat(boolean)

setFlat

public void setFlat(boolean isFlat)
Sets the flat appearance of this button. Fires a flat property change event.

Parameters:
isFlat - If true, this button will have flat appearance, otherwise this button will not have flat appearance.
See Also:
isFlat()

getActionModel

public ActionButtonModel getActionModel()
Returns the action model for this button.

Returns:
The action model for this button.
See Also:
setActionModel(ActionButtonModel)

setActionModel

public void setActionModel(ActionButtonModel newModel)
Sets the new action model for this button. Fires an actionModel property change event.

Parameters:
newModel - The new action model for this button.
See Also:
getActionModel()

addActionListener

public void addActionListener(ActionListener l)
Adds the specified action listener to this button.

Parameters:
l - Action listener to add.
See Also:
removeActionListener(ActionListener)

removeActionListener

public void removeActionListener(ActionListener l)
Removes the specified action listener from this button.

Parameters:
l - Action listener to remove.
See Also:
addActionListener(ActionListener)

addChangeListener

public void addChangeListener(ChangeListener l)
Adds the specified change listener to this button.

Parameters:
l - Change listener to add.
See Also:
removeChangeListener(ChangeListener)

removeChangeListener

public void removeChangeListener(ChangeListener l)
Removes the specified change listener from this button.

Parameters:
l - Change listener to remove.
See Also:
addChangeListener(ChangeListener)

setEnabled

public void setEnabled(boolean b)
Overrides:
setEnabled in class JComponent

fireStateChanged

protected void fireStateChanged()
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created.

See Also:
EventListenerList

fireActionPerformed

protected void fireActionPerformed(ActionEvent event)
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the event parameter.

Parameters:
event - the ActionEvent object
See Also:
EventListenerList

setHorizontalAlignment

public void setHorizontalAlignment(int alignment)
Sets new horizontal alignment for the content of this button. Fires a horizontalAlignment property change event.

Parameters:
alignment - New horizontal alignment for the content of this button.
See Also:
getHorizontalAlignment()

getHorizontalAlignment

public int getHorizontalAlignment()
Returns the horizontal alignment for the content of this button.

Returns:
The horizontal alignment for the content of this button.
See Also:
setHorizontalAlignment(int)

setHGapScaleFactor

public void setHGapScaleFactor(double hgapScaleFactor)
Sets new horizontal gap scale factor for the content of this button. Fires an hgapScaleFactor property change event.

Parameters:
hgapScaleFactor - New horizontal gap scale factor for the content of this button.
See Also:
getHGapScaleFactor(), setVGapScaleFactor(double), setGapScaleFactor(double)

setVGapScaleFactor

public void setVGapScaleFactor(double vgapScaleFactor)
Sets new vertical gap scale factor for the content of this button. Fires a vgapScaleFactor property change event.

Parameters:
vgapScaleFactor - New vertical gap scale factor for the content of this button.
See Also:
getVGapScaleFactor(), setHGapScaleFactor(double), setGapScaleFactor(double)

setGapScaleFactor

public void setGapScaleFactor(double gapScaleFactor)
Sets new gap scale factor for the content of this button.

Parameters:
gapScaleFactor - New gap scale factor for the content of this button.
See Also:
getHGapScaleFactor(), getVGapScaleFactor()

getHGapScaleFactor

public double getHGapScaleFactor()
Returns the horizontal gap scale factor for the content of this button.

Returns:
The horizontal gap scale factor for the content of this button.
See Also:
setHGapScaleFactor(double), setGapScaleFactor(double), getVGapScaleFactor()

getVGapScaleFactor

public double getVGapScaleFactor()
Returns the vertical gap scale factor for the content of this button.

Returns:
The vertical gap scale factor for the content of this button.
See Also:
setVGapScaleFactor(double), setGapScaleFactor(double), getHGapScaleFactor()

doActionClick

public void doActionClick()
Programmatically perform an action "click". This does the same thing as if the user had pressed and released the action area of the button.


setActionRichTooltip

public void setActionRichTooltip(RichTooltip richTooltip)
Sets the rich tooltip for the action area of this button.

Parameters:
richTooltip - Rich tooltip for the action area of this button.
See Also:
getRichTooltip(MouseEvent)

getRichTooltip

public RichTooltip getRichTooltip(MouseEvent mouseEvent)
Specified by:
getRichTooltip in class RichToolTipManager.JTrackableComponent

setToolTipText

public void setToolTipText(String text)
Overrides:
setToolTipText in class JComponent

getLocationOrderKind

public AbstractCommandButton.CommandButtonLocationOrderKind getLocationOrderKind()
Returns the location order kind for buttons placed in command button strips or for buttons that need the visuals of segmented strips.

Returns:
The location order kind for buttons placed in command button strips or for buttons that need the visuals of segmented strips.
See Also:
setLocationOrderKind(CommandButtonLocationOrderKind)

setLocationOrderKind

public void setLocationOrderKind(AbstractCommandButton.CommandButtonLocationOrderKind locationOrderKind)
Sets the location order kind for buttons placed in command button strips or for buttons that need the visuals of segmented strips. Fires a locationOrderKind property change event.

Parameters:
locationOrderKind - The location order kind for buttons placed in command button strips or for buttons that need the visuals of segmented strips.
See Also:
getLocationOrderKind()

getActionKeyTip

public String getActionKeyTip()
Returns the key tip for the action area of this button.

Returns:
The key tip for the action area of this button.
See Also:
setActionKeyTip(String)

setActionKeyTip

public void setActionKeyTip(String actionKeyTip)
Sets the key tip for the action area of this button. Fires an actionKeyTip property change event.

Parameters:
actionKeyTip - The key tip for the action area of this button.
See Also:
getActionKeyTip()