|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.AbstractAction | +--edu.ucsb.nceas.morpho.util.GUIAction
Class GUIAction This class extends javax.swing.AbstractAction in order to provide basic "Action" functionality for the GUI. Instances of this class are passed as arguments to Swing component constructors, in order to facilitate encapsulation and sharing of functionality (eg multiple ways of accessing the same command, such as from a drop-down menu and from a toolbar button). The Swing component generally adds this object to itself as an ActionListener automatically.
Field Summary | |
static int |
EVENT_GLOBAL
Public constant to denote that a GUIAction should consume events originating from any frame, not just its own |
static int |
EVENT_LOCAL
Public constant to denote that a GUIAction should consume events originating only within the same frame as the GUIAction itself |
Fields inherited from class javax.swing.AbstractAction |
changeSupport, enabled |
Fields inherited from interface javax.swing.Action |
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON |
Constructor Summary | |
GUIAction(java.lang.String name,
javax.swing.Icon icon,
Command cmd)
Constructor |
Method Summary | |
void |
actionPerformed(java.awt.event.ActionEvent actionEvent)
actionPerformed() method required by ActionListener interface |
GUIAction |
cloneAction()
Make a clone of the GUIAction instance. |
javax.swing.KeyStroke |
getAcceleratorKey()
Method to get accelerator key |
Command |
getCommand()
Get the command in this action object |
javax.swing.Icon |
getDefaultIcon()
gets the default Icon for this action object |
int |
getMenuItemPosition()
Get the menu item position for this action |
java.lang.String |
getMenuName()
Get the menu name for this action |
int |
getMenuPosition()
Get the menu position for this action |
static MorphoFrame |
getMorphoFrameAncestor(java.awt.Component c)
|
java.lang.String |
getName()
gets the text for the Name |
GUIAction |
getOriginalAction()
Get the original action from which a clone was made. |
java.lang.String |
getSeparatorPosition()
Get the separator position for this action |
javax.swing.Icon |
getSmallIcon()
Get the small Icon to be displayed on menus |
int |
getToolbarPosition()
Get the position of this action on the toolbar. |
java.lang.String |
getToolTipText()
gets the text for the tooltip |
void |
handleStateChange(StateChangeEvent event)
Handle a state change. |
void |
setAcceleratorKey(javax.swing.KeyStroke key)
Method to set accelerator key |
void |
setAcceleratorKeyString(java.lang.String keyString)
set a accelerator key for this action |
void |
setCommand(Command cmd)
Set the command in this action object |
void |
setCommandOnStateChange(java.lang.String changedState,
Command command,
int respondTo)
Set the state of this action to the enabled value if a state change matching changedState occurs. |
void |
setDefaultIcon(javax.swing.Icon icon)
Set the default icon. |
void |
setEnabledOnStateChange(java.lang.String changedState,
boolean enabled,
int respondTo)
Set the state of this action to the enabled value if a state change matching changedState occurs. |
void |
setMenu(java.lang.String menuName,
int position)
Sets the menu and its position for this action |
void |
setMenuItemPosition(int position)
sets the menu item position for this action |
void |
setSeparatorPosition(java.lang.String position)
sets the separator for this action |
void |
setSmallIcon(javax.swing.Icon smallIcon)
sets the small Icon to be displayed on menus |
void |
setSubMenu(boolean flag)
sets the action pull right submenu |
void |
setSubMenuPath(java.lang.String path)
sets the action path for sub menu or sub menuitem. |
void |
setToolbarPosition(int position)
Set the position of this action on the toolbar. |
void |
setToolTipText(java.lang.String toolTipText)
sets the text to be displayed as a mouse-over tooltip |
Methods inherited from class javax.swing.AbstractAction |
addPropertyChangeListener, clone, firePropertyChange, getKeys, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int EVENT_LOCAL
public static final int EVENT_GLOBAL
Constructor Detail |
public GUIAction(java.lang.String name, javax.swing.Icon icon, Command cmd)
name
- the display name of this action, as used in menusicon
- the default icon associated with this actioncmd
- the Command object that will have its execute() method
called by this object's actionPerformed() methodMethod Detail |
public GUIAction cloneAction()
public java.lang.String getName()
public javax.swing.Icon getDefaultIcon()
public void setDefaultIcon(javax.swing.Icon icon)
icon
- the icon to be used by defaultpublic java.lang.String getToolTipText()
public void setToolTipText(java.lang.String toolTipText)
toolTipText
- the tooltip text to be displayedpublic javax.swing.Icon getSmallIcon()
public void setSmallIcon(javax.swing.Icon smallIcon)
smallIcon
- the Icon to be displayed on menus etcpublic void setAcceleratorKeyString(java.lang.String keyString)
keyString
- the accelerator key stringpublic javax.swing.KeyStroke getAcceleratorKey()
public void setAcceleratorKey(javax.swing.KeyStroke key)
public void setSubMenu(boolean flag)
flag
- true of false the action is sub menupublic void setSubMenuPath(java.lang.String path)
path
- the supublic void setMenu(java.lang.String menuName, int position)
menuName
- the name of the menu in which to embed this actionposition
- the position of the menupublic java.lang.String getMenuName()
public int getMenuPosition()
public void setMenuItemPosition(int position)
position
- the position of memu itempublic int getMenuItemPosition()
public void setSeparatorPosition(java.lang.String position)
position
- the position separator of memu item, follow or precdingpublic java.lang.String getSeparatorPosition()
public void actionPerformed(java.awt.event.ActionEvent actionEvent)
actionPerformed
in class javax.swing.AbstractAction
actionEvent
- the event generated by the componentpublic Command getCommand()
public void setCommand(Command cmd)
public void setEnabledOnStateChange(java.lang.String changedState, boolean enabled, int respondTo)
changedState
- the name of the state changeenabled
- boolean value indicating whether the action should
be enabledlocalEventsOnly
- boolean value indicating whether the change should
occur in response only to events originating
within the same frame as this GUIAction's
containerrespondTo
- int value indicating whether the change should
occur in response only to events originating
within the same frame as this GUIAction's
container (GUIAction.EVENT_LOCAL) or in response
to all events, irrespective of their source
(GUIAction.EVENT_GLOBAL).public void setCommandOnStateChange(java.lang.String changedState, Command command, int respondTo)
changedState
- the name of the state changecommand
- Command that should be set upon a state changerespondTo
- int value indicating whether the change should
occur in response only to events originating
within the same frame as this GUIAction's
container (GUIAction.EVENT_LOCAL) or in response
to all events, irrespective of their source
(GUIAction.EVENT_GLOBAL).public void handleStateChange(StateChangeEvent event)
handleStateChange
in interface StateChangeListener
event
- the StateChangeEvent that has occurredpublic int getToolbarPosition()
public void setToolbarPosition(int position)
position
- the position of the action on the toolbarpublic GUIAction getOriginalAction()
public static MorphoFrame getMorphoFrameAncestor(java.awt.Component c)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |