Java The Complete Reference, Seventh Edition

(Greg DeLong) #1

Chapter 25: Images 785


idx = 0;
while (true) {
paint(getGraphics());
idx = (idx + 1) % nseq;
try {
Thread.sleep(1000/framerate);
} catch (InterruptedException e) {
System.out.println("Animation Interrupted");
return;
}
if(stopFlag)
return;
}
}
}


The following applet tag shows the famous locomotion study by Eadweard Muybridge,
which proved that horses do, indeed, get all four hooves off the ground at once. (Of course,
you can substitute another image file in your own applet.)









Figure 25-12 shows the applet running. Notice the source image that has been loaded below
the applet using a normal tag.


FIGURE 25-12

Sample output
ofAnimation

Free download pdf