AnimationAction.java

package com.bozoid.cis370.hw07;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.prefs.Preferences;


/**
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>Panel07</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,
        Panel07 cp,Animator a)
    {
        super(name);
        putValue(Action.SHORT_DESCRIPTION,tooltip);
        this.animator = a;
        this.contentPane = cp;
        prefs = Preferences.userRoot().node("/com/bozoid/cis370/hw07");
    }

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

    public Animator getAnimator()
    {
        return animator;
    }

    Preferences prefs;
    private Animator animator;
    private Panel07 contentPane;
}