FileDocCategorySizeDatePackage
TrackImage.javaAPI DocExample992Wed Mar 26 02:38:46 GMT 1997None

TrackImage

public class TrackImage extends Applet implements Runnable

Fields Summary
Image
img
final int
MAIN_IMAGE
MediaTracker
tracker
boolean
show
Thread
runme
String
message
Constructors Summary
Methods Summary
public voidinit()


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

		if ( show )
			g.drawImage( img, 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
			show = true;
		repaint();
	
public voidstart()

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

		runme.stop();
		runme = null;