Class Action

java.lang.Object
com.simsilica.lemur.Action
All Implemented Interfaces:
Command<Button>, VersionedObject<Action>
Direct Known Subclasses:
CallMethodAction, EmptyAction

public abstract class Action extends Object implements VersionedObject<Action>, Command<Button>
A combination of a command and some attributes that define what the GUI element should look like. The action is versioned so that GUI elements can automatically update themselves as these attributes are changed. This is similar to Swing's Action.
  • Field Details

  • Constructor Details

  • Method Details

    • execute

      public abstract void execute(Button source)
      Subclasses must override this to perform the action.
      Specified by:
      execute in interface Command<Button>
    • setEnabled

      public void setEnabled(boolean b)
      Sets the enabled/disabled state of this action. Action GUI elements that support being disabled will adhere to this state.
    • isEnabled

      public boolean isEnabled()
    • setSelected

      public void setSelected(boolean b)
      Sets the selected/deselected state of this action. Action GUI elements that support selection (checkboxes) will adhere to this state and reflect it back into the action itself.
    • isSelected

      public boolean isSelected()
    • setName

      public void setName(String name)
      Sets the name of the action that will be used as the label in wrapping Action GUI elements.
    • getName

      public String getName()
    • setIcon

      public void setIcon(GuiComponent component)
      Sets the icon that will be used as the icon in wrapping Action GUI elements. This is used when a smaller icon is needed or when there is no large icon specified.
    • getIcon

      public GuiComponent getIcon()
    • setLargeIcon

      public void setLargeIcon(GuiComponent component)
      Sets the icon that will be used as the icon in wrapping Action GUI elements. ActionButton will use this as its icon if specified. getLargeIcon() defaults to getIcon() when not set.
    • getLargeIcon

      public GuiComponent getLargeIcon()
    • putValue

      public void putValue(String key, Object value)
      Sets a general value onto this action that other action users or custom GUI elements can reference.
    • getValue

      public <T> T getValue(String key)
      Returns a previously set value from this action or null if the property has not been set.
    • getValue

      public <T> T getValue(String key, T defaultValue)
      Returns a previously set value from this action or defaultValue if the property has not been set.
    • incrementVersion

      protected void incrementVersion()
    • getVersion

      public long getVersion()
      Description copied from interface: VersionedObject
      Returns the current version of the versioned object.
      Specified by:
      getVersion in interface VersionedObject<Action>
    • getObject

      public Action getObject()
      Description copied from interface: VersionedObject
      Returns the object that is being versioned.
      Specified by:
      getObject in interface VersionedObject<Action>
    • createReference

      public VersionedReference<Action> createReference()
      Description copied from interface: VersionedObject
      Creates a new VersionedReference that can be used to monitor when this object changes.
      Specified by:
      createReference in interface VersionedObject<Action>
    • appendFields

      protected void appendFields(StringBuilder sb)
    • toString

      public String toString()
      Overrides:
      toString in class Object