FileDocCategorySizeDatePackage
StatusImage.javaAPI DocExample1219Sat Apr 23 22:35:40 BST 2005None

StatusImage

public class StatusImage extends JComponent

Fields Summary
boolean
loaded
String
message
Image
image
Constructors Summary
public StatusImage(Image image)


        this.image = image; 
Methods Summary
public voidloaded()

	loaded = true;
	repaint();
  
public static voidmain(java.lang.String[] args)

 
	JFrame frame = new JFrame("TrackImage");
    Image image = Toolkit.getDefaultToolkit().getImage( args[0] );
	StatusImage statusImage = new StatusImage( image );
	frame.getContentPane().add( statusImage );
	frame.setSize(300,300);
	frame.setVisible(true);

    MediaTracker tracker = new MediaTracker( statusImage );
	int MAIN_IMAGE = 0;
    tracker.addImage(image, MAIN_IMAGE);
    try { 
		tracker.waitForID(MAIN_IMAGE); }
    catch (InterruptedException e) {}
    if ( tracker.isErrorID(MAIN_IMAGE) ) 
		statusImage.setMessage("Error");
    else 
		statusImage.loaded();
  
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 voidsetMessage(java.lang.String msg)

	message = msg;
	repaint();