Homework #5 --
sample code
The instructor's version of
homework #5
implements two instances of each of three different animation
classes.
-
ActionTest05.java is the
main program.
-
Animator.java is an interface
describing a generic Animator object with one method,
oneFrame(Component comp,Graphics g).
-
Panel05.java is a thin subclass
of JPane with an instance variable that stores a
reference to an Animator.
-
AnimationAction.java
defines an AbstractAction subclass which switches
the current Animator in a Panel05.
-
Trajectory.java abstracts
the concept of a point bouncing around in a rectangular space.
-
AnimatedBalls.java
displays an animation of nballs balls bouncing around
in a Panel05. It uses one Trajectory for
each ball.
-
AnimatedLines.java
displays an animated set of nlines lines following
each other around in a Panel05.
It uses two Trajectory objects, one for each end of
a single line, and displays the lines corresponding to the
nlines most recent values of each.
-
Spinner.java implements a text
message spinning in the middle of a Panel05.
Here are some screen shots of the animations in action: