// First, force all the images to be loaded, and wait until
// they have all loaded completely.
for (int i = 0; i < num_images; i++) {
this.showStatus("Loading image: " + i);
// The argument is the same one we passed to addImage()
try { tracker.waitForID(i); } catch (InterruptedException e) { ; }
// Check for errors loading it.
if (tracker.isErrorID(i)) {
this.showStatus("Error loading image " + i + "; quitting.");
return;
}
}
this.showStatus("Loading images: done.");
// Now do the animation
while(true) {
if (++current_image >= images.length) current_image = 0;
this.getGraphics().drawImage(images[current_image], 0, 0, this);
this.getToolkit().sync(); // Force it to be drawn *now*.
try { Thread.sleep(200); } catch (InterruptedException e) { ; }
}