import java.awt.*;
import java.applet.*;

public class FastImage extends Applet
  {
    Image picture;
    boolean ImageLoaded = false;

    public void init()
      {
        picture = getImage(getCodeBase(), "Cows.gif");
        Image offScreenImage = createImage(size().width, size().height);
        Graphics offScreenGC = offScreenImage.getGraphics();
        offScreenGC.drawImage(picture, 0, 0, this);
      }

    public void paint(Graphics g)
      {
        if (ImageLoaded)
          {
            g.drawImage(picture, 0, 0, null);
            showStatus("Done");
          }
        else
          showStatus("Loading image");
      }

    public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h)
      {
         if (infoflags == ALLBITS)
           {
             ImageLoaded = true;
             repaint();
             return false;
           }
         else
           return true;
      }
  }


