Java Reference
In-Depth Information
import java.beans.*;
public class AnimBean 4 extends JPanel
implements ActionListener
{
private ImageIcon[] image;
private String imageName = "juggler";
private String oldImage = "juggler";
private int numFrames;
private int oldNumFrames = 0;
private int currentImage = 0;
private int delay = 100; //??
private Timer animTimer;
private PropertyChangeSupport changeSupport;
public static void main(String[] args)
{
AnimBean 4 anim = new AnimBean 4 ();
anim.setVisible(true);
}
public AnimBean 4 ()
{
changeSupport = new PropertyChangeSupport(this);
loadFrames();
startAnimation();
}
private void loadFrames()
{
//Check no. of frames fi rst…
numFrames = 0;
File fi leName =
new File(imageName + (numFrames) + ".gif");
while (fi leName.exists())
{
numFrames++;
fi leName =
new File(imageName + (numFrames) + ".gif");
}
if (numFrames==0) //No image found!
return; //Abandon loading of frames.
image = new ImageIcon[numFrames];
//Now load frames…
for (int i=0; i<numFrames; i++)
{
Search WWH ::




Custom Search