Class ToolAction

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.util.EventListener, javax.swing.Action

    public abstract class ToolAction
    extends java.lang.Object
    implements javax.swing.Action
    Standard template for creation of an Action to be used in a Tool.
    • Field Summary

      • 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

      Constructors 
      Constructor Description
      ToolAction​(UIFactory uif, java.lang.String key)
      Construct an internationalized action.
      ToolAction​(UIFactory uif, java.lang.String key, boolean needIcon)
      Construct an internationalized action.
      ToolAction​(I18NResourceBundle i18n, java.lang.String key)
      Construct an internationalized action.
      ToolAction​(java.lang.String name, java.lang.String desc, int mnemonic)
      Construct an action with a specific mnemonic.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)  
      java.lang.Object getValue​(java.lang.String key)
      Gets one of this object's properties using the associated key.
      boolean isEnabled()  
      void putValue​(java.lang.String key, java.lang.Object newVal)
      Sets one of this object's properties using the associated key.
      void removePropertyChangeListener​(java.beans.PropertyChangeListener listener)  
      void setEnabled​(boolean newVal)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface javax.swing.Action

        accept
      • Methods inherited from interface java.awt.event.ActionListener

        actionPerformed
    • Constructor Detail

      • ToolAction

        public ToolAction​(java.lang.String name,
                          java.lang.String desc,
                          int mnemonic)
        Construct an action with a specific mnemonic. This is the non-internationalized version and not recommended. See Action for details on the parameters.
        Parameters:
        name - Name of this action
        desc - Description of this action
        mnemonic - Mnemonic associated with this action
        See Also:
        Action
      • ToolAction

        public ToolAction​(UIFactory uif,
                          java.lang.String key)
        Construct an internationalized action.
        Parameters:
        uif - Factory to use for getting strings.
        key - Key for retrieving internationalized strings from the bundle.
        See Also:
        ToolAction(I18NResourceBundle, String)
      • ToolAction

        public ToolAction​(UIFactory uif,
                          java.lang.String key,
                          boolean needIcon)
        Construct an internationalized action.
        Parameters:
        uif - Factory to use for getting strings.
        key - Key for retrieving internationalized strings from the bundle.
        needIcon - True if an icon resource should be associated with this action. Will be retrieved through the uif. And put into the SMALL_ICON property.
        See Also:
        ToolAction(I18NResourceBundle, String), Action.SMALL_ICON
      • ToolAction

        public ToolAction​(I18NResourceBundle i18n,
                          java.lang.String key)
        Construct an internationalized action. The resources used are:
        uiKey.act the name for the button
        uiKey.tip the tool tip for the action
        uiKey.mne mnemonic for this action
        Parameters:
        i18n - Resource bundle to use when getting action properties
        key - Key for retrieving internationalized strings from the bundle.
    • Method Detail

      • getValue

        public java.lang.Object getValue​(java.lang.String key)
        Gets one of this object's properties using the associated key.
        Specified by:
        getValue in interface javax.swing.Action
        Parameters:
        key - the key of the property to be returned
        Returns:
        the value of the property with the given key
        See Also:
        putValue(java.lang.String, java.lang.Object)
      • putValue

        public void putValue​(java.lang.String key,
                             java.lang.Object newVal)
        Sets one of this object's properties using the associated key. If the value has changed, a PropertyChangeEvent is sent to listeners.
        Specified by:
        putValue in interface javax.swing.Action
        Parameters:
        key - the key of the property to be stored
        newVal - the new value for the property
      • isEnabled

        public boolean isEnabled()
        Specified by:
        isEnabled in interface javax.swing.Action
      • setEnabled

        public void setEnabled​(boolean newVal)
        Specified by:
        setEnabled in interface javax.swing.Action
      • addPropertyChangeListener

        public void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)
        Specified by:
        addPropertyChangeListener in interface javax.swing.Action
      • removePropertyChangeListener

        public void removePropertyChangeListener​(java.beans.PropertyChangeListener listener)
        Specified by:
        removePropertyChangeListener in interface javax.swing.Action