1 /* 2 * DrawLeaves.java 3 * This examples shows the use of the getImage and drawImage methods 4 * to download and display an image in a graphics area of an applet. 5 */ 6 7 import java.awt.Graphics; 8 import java.awt.Image; 9 10 public class DrawLeaves extends java.applet.Applet 11 { 12 Image leafimg, smalleafimg; 13 14 public void init() 15 { 16 leafimg = getImage(getCodeBase(), "images/Leaf.gif"); 17 } 18 19 public void paint(Graphics g) 20 { 21 // first draw it at regular size 22 g.drawImage(leafimg, 10, 10, this); 23 24 // use Image methods to find the width and height of the image 25 int w = leafimg.getWidth(this); 26 int h = leafimg.getHeight(this); 27 28 // now draw it at 1/4 size 29 g.drawImage(leafimg, 20 + w, 10, w/4, h/4, this); 30 } 31 } 32