/* * DrawLeaves.java * This examples shows the use of the getImage and drawImage methods * to download and display an image in a graphics area of an applet. */ import java.awt.Graphics; import java.awt.Image; public class DrawLeaves extends java.applet.Applet { Image leafimg; public void init() { leafimg = getImage(getCodeBase(), "images/Leaf.gif"); } public void paint(Graphics g) { // first draw it at regular size g.drawImage(leafimg, 10, 10, this); // use Image methods to find the width and height of the image int w = leafimg.getWidth(this); int h = leafimg.getHeight(this); // now draw it at 1/4 size g.drawImage(leafimg, 20 + w, 10, w/4, h/4, this); } }