public abstract class IlvAction extends AbstractAction
IlvAction
class is the abstract superclass of all
menu, toolbar, and registered keyboard actions in the Gantt module. The
standard Swing AbstractAction
class encapsulates an
action with a name and an optional icon. The IlvAction
class extends this by additionally encapsulating the action with a
keyboard accelerator and long and short description strings.changeSupport, enabled
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 and Description |
---|
IlvAction(String name)
Creates an
IlvAction object with the specified name. |
IlvAction(String name,
Icon icon)
Creates an
IlvAction object with the specified name and
the specified icon. |
IlvAction(String name,
Icon icon,
KeyStroke accelerator)
Creates an
IlvAction object with the specified name,
icon, and keystroke accelerator. |
IlvAction(String name,
Icon icon,
KeyStroke accelerator,
String shortDescription,
String longDescription)
Creates an
IlvAction object with the specified name,
icon, and description strings. |
Modifier and Type | Method and Description |
---|---|
KeyStroke |
getAccelerator()
Returns the key combination that will invoke the action.
|
String |
getAcceleratorText()
Returns the text representation of this action's accelerator.
|
Icon |
getIcon()
Returns the icon that represents this action visually, or
null if the action has no icon. |
String |
getLongDescription()
Returns the long description text that will typically be used for
display in the status bar, or
null if the action has no
long description. |
int |
getMnemonic()
Returns the keyboard mnemonic for the action.
|
String |
getName()
Returns the name of the action.
|
String |
getShortDescription()
Returns the short description text that will typically be used for
tooltips, or
null if the action has no short
description. |
void |
setAccelerator(KeyStroke keyStroke)
Sets the key combination that will invoke the action.
|
void |
setIcon(Class baseClass,
String file)
Sets the icon that will be used to represent this action visually.
|
void |
setIcon(Icon icon)
Sets the icon that will be used to represent this action visually.
|
void |
setLongDescription(String text)
Sets the long description text that will typically be used for display
in the status bar.
|
void |
setMnemonic(int mnemonic)
Sets the keyboard mnemonic for the action.
|
void |
setName(String name)
Sets the name of the action.
|
void |
setShortDescription(String text)
Sets the short description text that will typically be used for
tooltips.
|
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
actionPerformed
public IlvAction(String name)
IlvAction
object with the specified name.name
- The name of the action. If the action is added to a
JMenu
, the name will be used as the menu item
text. If the action is added to a JToolBar
,
the name will be used as the button text.public IlvAction(String name, Icon icon)
IlvAction
object with the specified name and
the specified icon.name
- The name of the action. If the action is added to a
JMenu
, the name will be used as the menu item
text. If the action is added to a JToolBar
,
the name will be used as the button text.icon
- The action's optional icon.public IlvAction(String name, Icon icon, KeyStroke accelerator)
IlvAction
object with the specified name,
icon, and keystroke accelerator.name
- The name of the action. If the action is added to a
JMenu
, the name will be used as the menu item
text. If the action is added to a JToolBar
,
the name will be used as the button text.icon
- The action's optional icon.accelerator
- The action's optional keyboard accelerator.public IlvAction(String name, Icon icon, KeyStroke accelerator, String shortDescription, String longDescription)
IlvAction
object with the specified name,
icon, and description strings.name
- The name of the action. If the action is added to a
JMenu
, the name will be used as the menu item
text. If the action is added to a JToolBar
,
the name will be used as the button text.icon
- The action's optional icon.accelerator
- The action's optional keyboard accelerator.shortDescription
- The action's optional short description. This
text, if not null
, will be typically used for
tooltips.longDescription
- The action's optional long description. This
text, if not null
, will be typically used for
display in a status bar.public String getName()
JMenu
, the name will be used as the menu item text. If
the action is added to a JToolBar
, the name will be
used as the button text.setName(java.lang.String)
public void setName(String name)
name
- The name of the action. If the action is added to a
JMenu
, the name will be used as the menu item
text. If the action is added to a JToolBar
,
the name will be used as the button text.getName()
public Icon getIcon()
null
if the action has no icon.setIcon(Icon)
public void setIcon(Icon icon)
icon
- The action icon or null
if the action has
no icon.getIcon()
public void setIcon(Class baseClass, String file)
baseClass
- The Class
object on which the method
getResourceAsStream
is called to read the icon
image file.file
- The location of the file that contains the icon image to
be read. The location must be specified relative to the
location of the baseClass
class.getIcon()
public KeyStroke getAccelerator()
null
if the action has no accelerator.setAccelerator(javax.swing.KeyStroke)
public String getAcceleratorText()
null
.getAccelerator()
public void setAccelerator(KeyStroke keyStroke)
getAccelerator()
public int getMnemonic()
VK_XXX
key codes defined in
java.awt.event.KeyEvent
, or zero if the action has no
mnemonic. If the action is set on a button or a menu item, the
mnemonic character will be underlined in the action
name
used as the button text.setMnemonic(int)
public void setMnemonic(int mnemonic)
VK_XXX
key codes defined in
java.awt.event.KeyEvent
, or zero if the action should
have no mnemonic. If the action is set on a button or a menu item, the
mnemonic character will be underlined in the action
name
used as the button text.mnemonic
- The key code that represents the mnemonic, or zero for
no mnemonic.getMnemonic()
public String getShortDescription()
null
if the action has no short
description.setShortDescription(java.lang.String)
public void setShortDescription(String text)
text
- The action's short description or null
if
the action has no short description.getShortDescription()
public String getLongDescription()
null
if the action has no
long description.setLongDescription(java.lang.String)
public void setLongDescription(String text)
text
- The action's long description or null
if
the action has no long description.getLongDescription()
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.