Class ActionTrigger

java.lang.Object
org.jdesktop.animation.timing.triggers.Trigger
org.jdesktop.animation.timing.triggers.ActionTrigger
All Implemented Interfaces:
ActionListener, EventListener

public class ActionTrigger extends Trigger implements ActionListener
ActionTrigger handles action events and starts the animator when actions occur. For example, to have anim start when a button is clicked, one might write the following:
     ActionTrigger trigger = ActionTrigger.addTrigger(button, anim);
 
  • Constructor Details

    • ActionTrigger

      public ActionTrigger(Animator animator)
      Creates an ActionTrigger that will start the animator upon receiving any ActionEvents. It should be added to any suitable object with an addActionListener method.
      Parameters:
      animator - the Animator that start when the event occurs
  • Method Details

    • addTrigger

      public static ActionTrigger addTrigger(Object object, Animator animator)
      Creates an ActionTrigger and adds it as a listener to object.
      Parameters:
      object - an object that will be used as an event source for this trigger. This object must have the method addActionListener.
      animator - the Animator that start when the event occurs
      Returns:
      ActionTrigger the resulting trigger
      Throws:
      IllegalArgumentException - if object has no addActionListener()
    • actionPerformed

      public void actionPerformed(ActionEvent ae)
      Called by an object generating ActionEvents to which this trigger was added as an ActionListener. This starts the Animator.
      Specified by:
      actionPerformed in interface ActionListener