AnimationAction.java

package com.bozoid.cis370.hw05;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;


/**
An AnimationAction will be attached to each object that changes 
the animation in the content pane.  When the action is performed, 
it merely changes the animator associated with the content pane.
Note that we pass a <code>Panel05</code>, rather than a
<code>JPanel</code>, because we have to call its 
<code>setAnimator()</code> method.
*/
public class AnimationAction extends AbstractAction
{
    public AnimationAction(String name,String tooltip,
        Panel05 cp,Animator a)
    {
        super(name);
        putValue(Action.SHORT_DESCRIPTION,tooltip);
        this.animator = a;
        this.contentPane = cp;
    }

    public void actionPerformed(ActionEvent e)
    {
        contentPane.setAnimator(animator);
    }

    private Animator animator;
    private Panel05 contentPane;
}