Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
/**
* Lab 2: MoveTimer.java
* A subclass of javax.swing.Timer that can be used for animation.
* It also serves as an example of the code for an "event source" object.
*/
public class MoveTimer extends javax.swing.Timer {
private Mover _mover; // peer object
private MoveListener _listener;
/**
* Constructor for the MoveTimer
*/
public MoveTimer (int anInterval, Mover aMover) {
// Instantiate the timer with a particular interval
super(anInterval, null);
// Save the peer object
_mover = aMover;
// Register a new MoveListener with the MoveTimer
_listener = new MoveListener();
this.addActionListener(_listener);
}
/**
* Internal class - MoveListener
*/
private class MoveListener implements java.awt.event.ActionListener {
/**
* The actionPerformed method specifies what is to me accomplished when
* the timer ticks
*/
public void actionPerformed(java.awt.event.ActionEvent e){
_mover.move();
}
}
}