translator
Class ExtendedAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by translator.ExtendedAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action

public class ExtendedAction
extends javax.swing.AbstractAction

This class represents an action object that allows calling methods on objects To use, simply invoke the ExtendedAction constructor by giving the label, icon name, tool tip text and the method to call (which currently must not have any parameters).

Version:
1.1 2000-10-22
Author:
Guido Rößling ( roessling@acm.org)
See Also:
Serialized Form

Field Summary
protected  javax.swing.AbstractButton wrapper
          The wrapper of the current Action element
 
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
ExtendedAction(java.lang.String objectKey, java.util.Locale locale, ExtendedResourceBundle bundle, java.lang.Object invocationTargetObject, Translator translator)
          Build a new object for invoking targetCall on the default Animal object
ExtendedAction(java.lang.String label, java.lang.String iconName, java.lang.String toolTipText, java.lang.String targetCall, java.lang.Object invocationTargetObject, java.lang.Object[] args, java.lang.String key, java.util.Hashtable<java.lang.String,ExtendedAction> hash, Translator translator)
          Build a new object for invoking targetCall on invocationTargetObject
ExtendedAction(java.lang.String label, java.lang.String iconName, java.lang.String toolTipText, java.lang.String targetCall, java.lang.Object invocationTargetObject, java.lang.Object[] args, Translator translator)
          Build a new object for invoking targetCall on invocationTargetObject
ExtendedAction(java.lang.String label, java.lang.String iconName, java.lang.String toolTipText, java.lang.String targetCall, java.lang.Object invocationTargetObject, Translator translator)
          Build a new object for invoking targetCall on invocationTargetObject
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent actionEvent)
          Handle the ActionEvent resulting once the object is activated This will try(!) to invoke the method on the target object
static ExtendedAction addToMenu(java.lang.String label, java.lang.String iconName, java.lang.String toolTipText, java.lang.String targetCall, java.lang.Object invocationTargetObject, java.lang.Object[] args, java.lang.String key, java.util.Hashtable<java.lang.String,ExtendedAction> hash, char mnemonic, javax.swing.JMenu menu, Translator translator)
          Build a new object for invoking targetCall on invocationTargetObject
static ExtendedAction addToToolBar(java.lang.String label, java.lang.String iconName, java.lang.String toolTipText, java.lang.String targetCall, java.lang.Object invocationTargetObject, java.lang.Object[] args, java.lang.String key, java.util.Hashtable<java.lang.String,ExtendedAction> hash, char mnemonic, javax.swing.JToolBar toolBar, Translator translator)
          Build a new object for invoking targetCall on invocationTargetObject
static ExtendedAction addToToolBar(java.lang.String label, java.lang.String iconName, java.lang.String toolTipText, java.lang.String targetCall, java.lang.Object invocationTargetObject, java.lang.Object[] args, java.lang.String key, java.util.Hashtable<java.lang.String,ExtendedAction> hash, javax.swing.JToolBar toolBar, Translator translator)
          Build a new object for invoking targetCall on invocationTargetObject
 java.lang.Object[] getArguments()
          Returns the arguments of the method call
 javax.swing.Icon getIcon()
          Return the icon to display
 java.lang.String getLabel()
          Return the label of this element
 java.lang.String getMethodToCall()
          Return the method to be invoked
 java.lang.Object getSmallIcon()
           
 java.lang.Object getTargetObject()
          Return the target object of the method invocation
 java.lang.String getToolTipText()
          Return the tool tip text
 Translator getTranslator()
          Return the Translator instance
static ExtendedAction insertAction(java.lang.String objectKey, java.util.Locale locale, ExtendedResourceBundle bundle, java.lang.Object invocationTargetObject, java.lang.Object[] arguments, java.util.Hashtable<java.lang.String,ExtendedAction> hash, char mnemonic, javax.swing.JToolBar toolBar, javax.swing.JMenu menu, Translator translator)
          Build a new object for invoking targetCall on invocationTargetObject
static ExtendedAction insertAction(java.lang.String objectKey, java.util.Locale locale, ExtendedResourceBundle bundle, java.lang.Object invocationTargetObject, java.lang.Object[] arguments, java.util.Hashtable<java.lang.String,ExtendedAction> hash, javax.swing.JToolBar toolBar, javax.swing.JMenu menu, Translator translator)
          Build a new object for invoking targetCall on invocationTargetObject
static ExtendedAction insertAction(java.lang.String label, java.lang.String iconName, java.lang.String toolTipText, java.lang.String targetCall, java.lang.Object invocationTargetObject, java.lang.Object[] args, java.lang.String key, java.util.Hashtable<java.lang.String,ExtendedAction> hash, char mnemonic, javax.swing.JToolBar toolBar, javax.swing.JMenu menu, Translator translator)
          Build a new object for invoking targetCall on invocationTargetObject
 void setArguments(java.lang.Object[] args)
          Sets the arguments of the method call
 void setIcon(javax.swing.Icon theIcon)
          Change the icon to display
 void setIcon(java.lang.String iconName)
          Change the icon to display
 void setLabel(java.lang.String label)
          Change the label to display
 void setMethod(java.lang.String methodName)
          Set the method to call
 void setObject(java.lang.Object target)
          Set the object whose method shall be invoked
 void setTargetCall(java.lang.String methodName, java.lang.Object target)
          Set the object on which the method of the given name shall be invoked
 void setToolTipText(java.lang.String toolTipText)
          Set the tool tip text
 java.lang.String toString()
          Provide a String representation of this object
 
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, wait, wait, wait
 

Field Detail

wrapper

protected javax.swing.AbstractButton wrapper
The wrapper of the current Action element

Constructor Detail

ExtendedAction

public ExtendedAction(java.lang.String objectKey,
                      java.util.Locale locale,
                      ExtendedResourceBundle bundle,
                      java.lang.Object invocationTargetObject,
                      Translator translator)
Build a new object for invoking targetCall on the default Animal object

Parameters:
objectKey - the key for this object, used for retrieving the localized information
locale - the current locale
bundle - the resource bundle used for retrieving the data from
invocationTargetObject - the object on which the method will be invoked

ExtendedAction

public ExtendedAction(java.lang.String label,
                      java.lang.String iconName,
                      java.lang.String toolTipText,
                      java.lang.String targetCall,
                      java.lang.Object invocationTargetObject,
                      Translator translator)
Build a new object for invoking targetCall on invocationTargetObject

Parameters:
label - the String label shown on the action element
iconName - the filename of the icon to use (which is loaded automatically)
toolTipText - the text of the tool tip
targetCall - the method to invoke once the ExtendedAction object is activated
invocationTargetObject - the object on which the method will be invoked

ExtendedAction

public ExtendedAction(java.lang.String label,
                      java.lang.String iconName,
                      java.lang.String toolTipText,
                      java.lang.String targetCall,
                      java.lang.Object invocationTargetObject,
                      java.lang.Object[] args,
                      Translator translator)
Build a new object for invoking targetCall on invocationTargetObject

Parameters:
label - the String label shown on the action element
iconName - the filename of the icon to use (which is loaded automatically)
toolTipText - the text of the tool tip
targetCall - the method to invoke once the ExtendedAction object is activated
invocationTargetObject - the object on which the method will be invoked
args - the arguments for the method invocation

ExtendedAction

public ExtendedAction(java.lang.String label,
                      java.lang.String iconName,
                      java.lang.String toolTipText,
                      java.lang.String targetCall,
                      java.lang.Object invocationTargetObject,
                      java.lang.Object[] args,
                      java.lang.String key,
                      java.util.Hashtable<java.lang.String,ExtendedAction> hash,
                      Translator translator)
Build a new object for invoking targetCall on invocationTargetObject

Parameters:
label - the String label shown on the action element
iconName - the filename of the icon to use (which is loaded automatically)
toolTipText - the text of the tool tip
targetCall - the method to invoke once the ExtendedAction object is activated
invocationTargetObject - the object on which the method will be invoked
args - the arguments for the method invocation
key - the key for this action when stored in the Hashtable
hash - the Hashtable storing the actions or null if none is used
Method Detail

addToToolBar

public static ExtendedAction addToToolBar(java.lang.String label,
                                          java.lang.String iconName,
                                          java.lang.String toolTipText,
                                          java.lang.String targetCall,
                                          java.lang.Object invocationTargetObject,
                                          java.lang.Object[] args,
                                          java.lang.String key,
                                          java.util.Hashtable<java.lang.String,ExtendedAction> hash,
                                          javax.swing.JToolBar toolBar,
                                          Translator translator)
Build a new object for invoking targetCall on invocationTargetObject

Parameters:
label - the String label shown on the action element
iconName - the filename of the icon to use (which is loaded automatically)
toolTipText - the text of the tool tip
targetCall - the method to invoke once the ExtendedAction object is activated
invocationTargetObject - the object on which the method will be invoked
args - the arguments for the method invocation
key - the key for this action when stored in the Hashtable
hash - the Hashtable storing the actions or null if none is used
toolBar - the JToolBar to which the element is added
Returns:
the ExtendedAction object generated

addToToolBar

public static ExtendedAction addToToolBar(java.lang.String label,
                                          java.lang.String iconName,
                                          java.lang.String toolTipText,
                                          java.lang.String targetCall,
                                          java.lang.Object invocationTargetObject,
                                          java.lang.Object[] args,
                                          java.lang.String key,
                                          java.util.Hashtable<java.lang.String,ExtendedAction> hash,
                                          char mnemonic,
                                          javax.swing.JToolBar toolBar,
                                          Translator translator)
Build a new object for invoking targetCall on invocationTargetObject

Parameters:
label - the String label shown on the action element
iconName - the filename of the icon to use (which is loaded automatically)
toolTipText - the text of the tool tip
targetCall - the method to invoke once the ExtendedAction object is activated
invocationTargetObject - the object on which the method will be invoked
args - the arguments for the method invocation
key - the key for this action when stored in the Hashtable
hash - the Hashtable storing the actions or null if none is used
mnemonic - the mnemonic to be used for the element
toolBar - the JToolBar to which the element is added
translator - the Translator used for I18N
Returns:
the ExtendedAction object generated

addToMenu

public static ExtendedAction addToMenu(java.lang.String label,
                                       java.lang.String iconName,
                                       java.lang.String toolTipText,
                                       java.lang.String targetCall,
                                       java.lang.Object invocationTargetObject,
                                       java.lang.Object[] args,
                                       java.lang.String key,
                                       java.util.Hashtable<java.lang.String,ExtendedAction> hash,
                                       char mnemonic,
                                       javax.swing.JMenu menu,
                                       Translator translator)
Build a new object for invoking targetCall on invocationTargetObject

Parameters:
label - the String label shown on the action element
iconName - the filename of the icon to use (which is loaded automatically)
toolTipText - the text of the tool tip
targetCall - the method to invoke once the ExtendedAction object is activated
invocationTargetObject - the object on which the method will be invoked
args - the arguments for the method invocation
key - the key for this action when stored in the Hashtable
hash - the Hashtable storing the actions or null if none is used
mnemonic - the mnemonic to be used for the element
menu - the JMenu to which the element is added
translator - the Translator used for I18N
Returns:
the ExtendedAction object generated

insertAction

public static ExtendedAction insertAction(java.lang.String label,
                                          java.lang.String iconName,
                                          java.lang.String toolTipText,
                                          java.lang.String targetCall,
                                          java.lang.Object invocationTargetObject,
                                          java.lang.Object[] args,
                                          java.lang.String key,
                                          java.util.Hashtable<java.lang.String,ExtendedAction> hash,
                                          char mnemonic,
                                          javax.swing.JToolBar toolBar,
                                          javax.swing.JMenu menu,
                                          Translator translator)
Build a new object for invoking targetCall on invocationTargetObject

Parameters:
label - the String label shown on the action element
iconName - the filename of the icon to use (which is loaded automatically)
toolTipText - the text of the tool tip
targetCall - the method to invoke once the ExtendedAction object is activated
invocationTargetObject - the object on which the method will be invoked
args - the arguments for the method invocation
key - the key for this action when stored in the Hashtable
hash - the Hashtable storing the actions or null if none is used
mnemonic - the mnemonic to be used for the element
toolBar - the JToolBar to which the element is added
menu - the JMenu to which the element is added
translator - the Translator used for I18N
Returns:
the ExtendedAction object generated

insertAction

public static ExtendedAction insertAction(java.lang.String objectKey,
                                          java.util.Locale locale,
                                          ExtendedResourceBundle bundle,
                                          java.lang.Object invocationTargetObject,
                                          java.lang.Object[] arguments,
                                          java.util.Hashtable<java.lang.String,ExtendedAction> hash,
                                          javax.swing.JToolBar toolBar,
                                          javax.swing.JMenu menu,
                                          Translator translator)
Build a new object for invoking targetCall on invocationTargetObject

Parameters:
objectKey - the key for the element
locale - the locale to be used for the label
bundle - the animalResourceBundle used for translating the label
invocationTargetObject - the object on which the method will be invoked
arguments - the arguments for the method invocation
hash - the Hashtable storing the actions or null if none is used
toolBar - the JToolBar to which the element is added
menu - the JMenu to which the element is added
Returns:
the ExtendedAction object generated

insertAction

public static ExtendedAction insertAction(java.lang.String objectKey,
                                          java.util.Locale locale,
                                          ExtendedResourceBundle bundle,
                                          java.lang.Object invocationTargetObject,
                                          java.lang.Object[] arguments,
                                          java.util.Hashtable<java.lang.String,ExtendedAction> hash,
                                          char mnemonic,
                                          javax.swing.JToolBar toolBar,
                                          javax.swing.JMenu menu,
                                          Translator translator)
Build a new object for invoking targetCall on invocationTargetObject

Parameters:
objectKey - the key for the element
locale - the locale to be used for the label
bundle - the animalResourceBundle used for translating the label
invocationTargetObject - the object on which the method will be invoked
arguments - the arguments for the method invocation
hash - the Hashtable storing the actions or null if none is used
mnemonic - the mnemonic to be used for the element
toolBar - the JToolBar to which the element is added
menu - the JMenu to which the element is added
translator - the Translator used for I18N
Returns:
the ExtendedAction object generated

getArguments

public java.lang.Object[] getArguments()
Returns the arguments of the method call

Returns:
the arguments for the method call

getIcon

public javax.swing.Icon getIcon()
Return the icon to display

Returns:
the icon used in the display

getLabel

public java.lang.String getLabel()
Return the label of this element

Returns:
the label of this element

getMethodToCall

public java.lang.String getMethodToCall()
Return the method to be invoked

Returns:
the method to be invoked

getSmallIcon

public java.lang.Object getSmallIcon()

getTargetObject

public java.lang.Object getTargetObject()
Return the target object of the method invocation

Returns:
the target object for the method invocation

getToolTipText

public java.lang.String getToolTipText()
Return the tool tip text

Returns:
the text displayed on the tool tip of this Action element

getTranslator

public Translator getTranslator()
Return the Translator instance

Returns:
the Translator instance used for this context

setArguments

public void setArguments(java.lang.Object[] args)
Sets the arguments of the method call

Parameters:
args - the arguments for the method call

setIcon

public void setIcon(javax.swing.Icon theIcon)
Change the icon to display

Parameters:
theIcon - the icon to use

setIcon

public void setIcon(java.lang.String iconName)
Change the icon to display

Parameters:
iconName - the name of the icon to use

setLabel

public void setLabel(java.lang.String label)
Change the label to display

Parameters:
label - the new label to use

setMethod

public void setMethod(java.lang.String methodName)
Set the method to call

Parameters:
methodName - the name of the method to invoke

setObject

public void setObject(java.lang.Object target)
Set the object whose method shall be invoked

Parameters:
target - the object whose method is to be called

setTargetCall

public void setTargetCall(java.lang.String methodName,
                          java.lang.Object target)
Set the object on which the method of the given name shall be invoked

Parameters:
methodName - the name of the method to invoke
target - the object whose method is to be called

setToolTipText

public void setToolTipText(java.lang.String toolTipText)
Set the tool tip text

Parameters:
toolTipText - the text displayed on the tool tip of this Action element

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent actionEvent)
Handle the ActionEvent resulting once the object is activated This will try(!) to invoke the method on the target object

Parameters:
actionEvent - the ActionEvent object

toString

public java.lang.String toString()
Provide a String representation of this object

Overrides:
toString in class java.lang.Object
Returns:
the String representation of this object