import java.applet.Applet;
import java.awt.*;

// This appears in Core Web Programming from
// Prentice Hall Publishers, and may be freely used
// or adapted. 1997 Marty Hall, hall@apl.jhu.edu.

/** A class that incorrectly tries to load an
 *  image and draw an outline around it.
 *  Don't try this at home.
 */
public class ImageBox extends Applet {
  private int imageWidth, imageHeight;
  private Image image;

  public void init() {
    String imageName = getParameter("IMAGE");
    if (imageName != null)
      image = getImage(getDocumentBase(), imageName);
    else 
      image = getImage(getDocumentBase(), "error.gif");
    setBackground(Color.white);
    
    // The following is wrong, since the image
    // won't be done loading, and -1 will be
    // returned.
    imageWidth = image.getWidth(this);
    imageHeight = image.getHeight(this);
  }

  public void paint(Graphics g) {
    g.drawImage(image, 0, 0, this);
    g.drawRect(0, 0, imageWidth, imageHeight);
  }
}
    

