com.borland.primetime.actions
Class ActionButton

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--com.borland.primetime.actions.ActionButton

public class ActionButton
extends javax.swing.JComponent
implements ActionWidget

The ActionButton is a UI widget that represents a single Action object. ActionButtons represent Action objects by showing their small icon, short text in a tooltip, and mirroring their enabled state. When an ActionButton is clicked, it calls its associated Action's actionPerformed method.

ActionButtons are constructed with a source Object and an Action to represent. The source Object will be passed as the source of the ActionEvent to the assoicated Action's actionPerformed method. This allows an ActionButton to pass a particular source object (not the button itself), so the associated Actions can have direct access to a specific Object. This source is determined by the code that instantiates the ActionButton.

ActionButtons that are associated with UpdateableActions will add themselves to a timer that automatically updates the state of the action at regular intervals.

ActionButtons also have special functionality to represent StateAction objects - they will appear depressed when the StateAction's state property is 'true' and flat when it is 'false'.

See Also:
Action, UpdateableAction, StateAction, Serialized Form

Inner Class Summary
 class ActionButton.ActionPropertyChangeListener
           
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
protected  javax.swing.Action action
           
protected  java.awt.event.ActionEvent ae
           
protected  boolean center
           
protected  java.awt.Image dither
           
protected static int DOWN
           
protected  int fixedHeight
           
protected  int fixedWidth
           
protected static int FLAT
           
protected  int gapSize
           
protected static boolean globalMouseDown
           
protected static boolean globalPopping
           
protected  boolean glowStyle
           
protected  javax.swing.Icon icon
           
protected  javax.swing.Icon icon_dis
           
protected static javax.swing.Icon icon_marker
           
protected  javax.swing.Icon icon_roll
           
protected  java.lang.String longText
           
protected  boolean mouseDown
           
protected  java.beans.PropertyChangeListener pcl
           
protected  boolean popping
           
protected  int popWidth
           
protected  boolean rollover
           
protected  java.lang.String shortText
           
protected  boolean showIcon
           
protected  boolean showRips
           
protected  boolean showText
           
protected  java.lang.Object source
           
protected static int UP
           
protected  boolean useSmallIcon
           
 
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
 
Constructor Summary
ActionButton(java.lang.Object source, javax.swing.Action action)
          Constructs an ActionButton with the specified source and action objects.
ActionButton(java.lang.Object source, javax.swing.Action action, java.awt.Dimension fixedSize)
          Constructs an ActionButton with the specified source and action objects, using the specified button size.
ActionButton(java.lang.Object source, javax.swing.Action action, java.awt.Dimension fixedSize, boolean useSmallIcon)
          Constructs an ActionButton with the specified source and action objects, using the specified button size, and the useSmallIcon setting.
 
Method Summary
 void addNotify()
           
protected  int buttonPopState()
           
 void clear()
           
 javax.swing.JToolTip createToolTip()
           
 void drawBorder(java.awt.Graphics g, java.awt.Rectangle r, boolean up)
           
 void drawPopArrow(java.awt.Graphics g, java.awt.Rectangle r)
           
protected  void fire()
           
 javax.swing.Action getAction()
          Returns the Action for this ActionButton.
 int getFixedHeight()
           
 java.awt.Dimension getFixedSize()
          Returns the button size.
 int getFixedWidth()
           
 int getGapSize()
           
 java.awt.Dimension getPreferredSize()
           
 java.lang.Object getSource()
          Returns the object source for this ActionButton.
protected  boolean hasPopBar()
           
protected  void initButton()
           
 boolean isCentered()
           
 boolean isFocusTraversable()
           
 boolean isGlowStyle()
          Returns the glowStyle property setting.
 boolean isShowIcon()
           
 boolean isShowRips()
           
 boolean isShowText()
           
 boolean isUseSmallIcon()
          Returns the useSmallIcon property setting.
 void paintChildren(java.awt.Graphics g)
           
 void paintComponent(java.awt.Graphics g)
           
protected  int popPopState()
           
protected  void processMouseEvent(java.awt.event.MouseEvent e)
           
 void removeNotify()
           
 void setCentered(boolean center)
           
 void setFixedHeight(int height)
           
 void setFixedSize(java.awt.Dimension d)
          Sets the button size.
 void setFixedWidth(int width)
           
 void setGapSize(int gap)
           
 void setGlowStyle(boolean glow)
          Sets the glowStyle property.
 void setIcon(javax.swing.Icon i)
          Sets the icon for the ActionButton.
protected  void setLongText(java.lang.String longText)
           
protected  void setShortText(java.lang.String shortText)
           
 void setShowIcon(boolean showIcon)
           
 void setShowRips(boolean rips)
           
 void setShowText(boolean showText)
           
 void setToolTipText(java.lang.String text)
           
 void setUseSmallIcon(boolean useSmall)
          Sets the useSmallIcon property.
protected  javax.swing.Icon theIcon()
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintImmediately, paintImmediately, paramString, print, printAll, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setUI, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setCursor, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processInputMethodEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UP

protected static final int UP

FLAT

protected static final int FLAT

DOWN

protected static final int DOWN

globalMouseDown

protected static boolean globalMouseDown

globalPopping

protected static boolean globalPopping

icon_marker

protected static javax.swing.Icon icon_marker

fixedWidth

protected int fixedWidth

fixedHeight

protected int fixedHeight

popWidth

protected int popWidth

ae

protected java.awt.event.ActionEvent ae

source

protected java.lang.Object source

action

protected javax.swing.Action action

useSmallIcon

protected boolean useSmallIcon

icon

protected javax.swing.Icon icon

icon_dis

protected javax.swing.Icon icon_dis

icon_roll

protected javax.swing.Icon icon_roll

gapSize

protected int gapSize

shortText

protected java.lang.String shortText

longText

protected java.lang.String longText

rollover

protected boolean rollover

mouseDown

protected boolean mouseDown

popping

protected boolean popping

showIcon

protected boolean showIcon

showText

protected boolean showText

showRips

protected boolean showRips

center

protected boolean center

glowStyle

protected boolean glowStyle

dither

protected java.awt.Image dither

pcl

protected java.beans.PropertyChangeListener pcl
Constructor Detail

ActionButton

public ActionButton(java.lang.Object source,
                    javax.swing.Action action)
Constructs an ActionButton with the specified source and action objects.
Parameters:
source - The source object
action - The action object

ActionButton

public ActionButton(java.lang.Object source,
                    javax.swing.Action action,
                    java.awt.Dimension fixedSize)
Constructs an ActionButton with the specified source and action objects, using the specified button size.

ActionButton

public ActionButton(java.lang.Object source,
                    javax.swing.Action action,
                    java.awt.Dimension fixedSize,
                    boolean useSmallIcon)
Constructs an ActionButton with the specified source and action objects, using the specified button size, and the useSmallIcon setting.
Method Detail

clear

public void clear()

setFixedSize

public void setFixedSize(java.awt.Dimension d)
Sets the button size.
Parameters:
d - The new button size

getFixedSize

public java.awt.Dimension getFixedSize()
Returns the button size.
Returns:
The button size

setFixedWidth

public void setFixedWidth(int width)

getFixedWidth

public int getFixedWidth()

setFixedHeight

public void setFixedHeight(int height)

getFixedHeight

public int getFixedHeight()

setGapSize

public void setGapSize(int gap)

getGapSize

public int getGapSize()

setShowIcon

public void setShowIcon(boolean showIcon)

isShowIcon

public boolean isShowIcon()

setShowText

public void setShowText(boolean showText)

isShowText

public boolean isShowText()

setShowRips

public void setShowRips(boolean rips)

isShowRips

public boolean isShowRips()

setCentered

public void setCentered(boolean center)

isCentered

public boolean isCentered()

setGlowStyle

public void setGlowStyle(boolean glow)
Sets the glowStyle property. When the glowStyle is set to true, the icons will glow as the mouse moves over them. When the glowStyle is set to false, the ActionButtons pop up as the mouse moves over them. By default, the glow style is false.
Parameters:
glow - The glow style stetting for this ActionButton

isGlowStyle

public boolean isGlowStyle()
Returns the glowStyle property setting.
Returns:
The glow style stetting for all ActionButtons

setUseSmallIcon

public void setUseSmallIcon(boolean useSmall)
Sets the useSmallIcon property. When set to true (default), the SMALL_ICON value will be used on the ActionButton. When set to false, the LARGE_ICON value is used.
Parameters:
useSmall - The useSmallIcon property setting

isUseSmallIcon

public boolean isUseSmallIcon()
Returns the useSmallIcon property setting.
Returns:
The useSmallIcon property setting

setIcon

public void setIcon(javax.swing.Icon i)
Sets the icon for the ActionButton. When an icon is set, a few other icons are auto-generated, including a disabled version, and possibly a rollover version if the 'glowStyle' property is set.
Parameters:
i - The icon for the ActionButton

getSource

public java.lang.Object getSource()
Returns the object source for this ActionButton.
Specified by:
getSource in interface ActionWidget
Returns:
The source object

getAction

public javax.swing.Action getAction()
Returns the Action for this ActionButton.
Specified by:
getAction in interface ActionWidget
Returns:
The Action

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class javax.swing.JComponent

isFocusTraversable

public boolean isFocusTraversable()
Overrides:
isFocusTraversable in class javax.swing.JComponent

setToolTipText

public void setToolTipText(java.lang.String text)
Overrides:
setToolTipText in class javax.swing.JComponent

setLongText

protected void setLongText(java.lang.String longText)

setShortText

protected void setShortText(java.lang.String shortText)

addNotify

public void addNotify()
Overrides:
addNotify in class javax.swing.JComponent

removeNotify

public void removeNotify()
Overrides:
removeNotify in class javax.swing.JComponent

createToolTip

public javax.swing.JToolTip createToolTip()
Overrides:
createToolTip in class javax.swing.JComponent

initButton

protected void initButton()

fire

protected void fire()

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent e)
Overrides:
processMouseEvent in class java.awt.Component

hasPopBar

protected boolean hasPopBar()

buttonPopState

protected int buttonPopState()

popPopState

protected int popPopState()

theIcon

protected javax.swing.Icon theIcon()

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

drawPopArrow

public void drawPopArrow(java.awt.Graphics g,
                         java.awt.Rectangle r)

drawBorder

public void drawBorder(java.awt.Graphics g,
                       java.awt.Rectangle r,
                       boolean up)

paintChildren

public void paintChildren(java.awt.Graphics g)
Overrides:
paintChildren in class javax.swing.JComponent