FileDocCategorySizeDatePackage
TrackImage.javaAPI DocExample1118Mon May 01 14:42:06 BST 2000None

TrackImage

public class TrackImage extends JApplet implements Runnable

Fields Summary
final int
MAIN_IMAGE
Image
image
MediaTracker
tracker
boolean
loaded
Thread
thread
String
message
Constructors Summary
Methods Summary
public voidinit()


       
    image = getImage(getClass(  ).getResource(getParameter("image")));
    tracker = new MediaTracker(this);
    tracker.addImage(image, MAIN_IMAGE);
  
public voidpaint(java.awt.Graphics g)

    if (loaded) g.drawImage(image, 0, 0, this);
    else {
      g.drawRect(0, 0, getSize().width - 1, getSize(  ).height - 1);
      g.drawString(message, 20, 20);
    }
  
public voidrun()

    repaint(  );
    try { tracker.waitForID(MAIN_IMAGE); }
    catch(InterruptedException e) {}
    if (tracker.isErrorID(MAIN_IMAGE)) message = "Error";
    else loaded = true;
    repaint(  );
  
public voidstart()

    if (!tracker.checkID(MAIN_IMAGE)) {
      thread = new Thread(this);
      thread.start(  );
    }
  
public voidstop()

    thread.interrupt(  );
    thread = null;