info.rolandkrueger.roklib.ui.swing
Class AbstractHoverableAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by info.rolandkrueger.roklib.ui.swing.AbstractHoverableAction
All Implemented Interfaces:
Hoverable, ActionListener, Serializable, Cloneable, EventListener, Action

public abstract class AbstractHoverableAction
extends AbstractAction
implements Hoverable

This subclass of AbstractAction enhances the action classes with the ability of using hover messages. If the user points at one of the GUI representations of the AbstractHoverableAction, a predefined message can be displayed by all HoverListeners that have been registered as listeners with the action object.

In order for this feature to work, an AbstractHoverableAction must be added to a menu bar or a tool bar by using methods attachToMenu(JMenu) and attachToToolbar(JToolBar), respectively.

Author:
Roland Krueger
See Also:
Hoverable, HoverManager, HoverListener, Serialized Form

Field Summary
protected  JButton mButton
           
private  HoverManager mHoverManager
           
protected  JMenuItem mMenuItem
           
private static long serialVersionUID
           
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
AbstractHoverableAction(String name, Icon icon)
          Constructs a new AbstractHoverableAction.
 
Method Summary
 boolean addHoverListener(HoverListener listener)
          Add a HoverListener to the list of listeners.
 void attachToMenu(JMenu menu)
          Attach this AbstractHoverableAction to the given menu.
 void attachToToolbar(JToolBar toolbar)
          Attach this AbstractHoverableAction to the given toolbar.
 String getHoverText()
          Gets the hover text for this action.
 void setHoverMessage(String hoverMessage)
          Sets the message that can be displayed during hover events.
 void setMnemonicKey(int mnemonicKey)
          Sets the short key for this action.
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

mButton

protected JButton mButton

mMenuItem

protected JMenuItem mMenuItem

mHoverManager

private HoverManager mHoverManager
Constructor Detail

AbstractHoverableAction

public AbstractHoverableAction(String name,
                               Icon icon)
Constructs a new AbstractHoverableAction.

See Also:
AbstractAction.AbstractAction(java.lang.String, javax.swing.Icon)
Method Detail

attachToToolbar

public void attachToToolbar(JToolBar toolbar)
Attach this AbstractHoverableAction to the given toolbar. By using this method, the correct MouseListeners will be registered so that hover events will correctly by disseminated.

Parameters:
toolbar - target toolbar that this action will be added to

attachToMenu

public void attachToMenu(JMenu menu)
Attach this AbstractHoverableAction to the given menu. By using this method, the correct MouseListeners will be registered so that hover events will correctly by disseminated.

Parameters:
menu - target menu that this action will be added to

getHoverText

public String getHoverText()
Gets the hover text for this action.

Specified by:
getHoverText in interface Hoverable
Returns:
the hover text for this action

addHoverListener

public boolean addHoverListener(HoverListener listener)
Add a HoverListener to the list of listeners.

Parameters:
listener - a HoverListener registering for hover events
Returns:
true

setHoverMessage

public void setHoverMessage(String hoverMessage)
Sets the message that can be displayed during hover events.

Parameters:
hoverMessage - a help message for this action

setMnemonicKey

public void setMnemonicKey(int mnemonicKey)
Sets the short key for this action.

Parameters:
mnemonicKey - one of the key constants as defined in Action.


Copyright © 2007-2011. All Rights Reserved.