The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.applet  [8 examples] > Images  [2 examples]

e557. Loading and Drawing an Image in an Applet

See also e551 The Quintessential Applet.
    Image image;
    public void init() {
        // Load image
        image = getImage(getDocumentBase(), "http://hostname/image.gif");
    }
    public void paint(Graphics g) {
        // Draw image
        g.drawImage(image, 0, 0, this);
    }

 Related Examples
e558. Animating an Array of Images in an Applet

See also: Sound   


© 2002 Addison-Wesley.