img
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.)
<applet code=Animation width=67 height=48>
<param name=img value=horse.gif>
<param name=rows value=3>
<param name=cols value=4>
<param name=sequence value=0,1,2,3,4,5,6,7,8,9,10,11>
<param name=framerate value=15>
</applet>
Figure 25-12 shows the applet running. Notice the source image that has been loaded below
the applet using a normal <img> tag.
FIGURE 25-12
Sample output
of Animation
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home