import java.awt.*;
import java.applet.*;
public class trackImage extends Applet implements Runnable {
Thread play;
Image thePicture;
MediaTracker theTracker;
public void init() {
thePicture = getImage(getDocumentBase(), getParameter("imagefile"));
theTracker = new MediaTracker(this);
theTracker.addImage(thePicture, 1);
play = new Thread(this);
play.start();
}
public void run() {
try {
theTracker.waitForID(1);
repaint();
}
catch (InterruptedException ie) {
}
}
public void paint(Graphics g) {
if (theTracker.checkID(1, true)) {
g.drawImage(thePicture, 0, 0, this);
play.stop();
}
else {
g.drawString("Loading Picture. Please hang on", 25, 50);
}
}
}
|