import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.net.*;

class FetchImage extends Frame {

  /*  Fetch an image program  by  J M Bishop  Jan 1997
   *  ======================  Java 1.1
   *                          updated B Worrall Aug 2000

   *  Fetches a jpg or gif image into a window.
   *  Illustrates use of awt.image. */

  private Image image;

  public void paint(Graphics g) {
    g.drawImage(image, 50, 50, this);
  }

  public static void main(String[] args) throws Exception {
    new FetchImage(args[0]);
  }

  FetchImage (String name) throws Exception {
    URL imageURL = new URL(name);
    image = createImage((ImageProducer) imageURL.getContent());
    setSize(300, 300);
    setVisible(true);
    addWindowListener(new WindowAdapter () {
      public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    });
 }
}
