Class ActionTrigger

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

    public class ActionTrigger
    extends Trigger
    implements java.awt.event.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 Summary

      Constructors 
      Constructor Description
      ActionTrigger​(Animator animator)
      Creates an ActionTrigger that will start the animator upon receiving any ActionEvents.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent ae)
      Called by an object generating ActionEvents to which this trigger was added as an ActionListener.
      static ActionTrigger addTrigger​(java.lang.Object object, Animator animator)
      Creates an ActionTrigger and adds it as a listener to object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • 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 Detail

      • addTrigger

        public static ActionTrigger addTrigger​(java.lang.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:
        java.lang.IllegalArgumentException - if object has no addActionListener()
      • actionPerformed

        public void actionPerformed​(java.awt.event.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 java.awt.event.ActionListener