import java.awt.*; import javax.swing.JApplet; public class TilingApplet extends JApplet { // define constants private final int APPLET_WIDTH = 320; private final int APPLET_HEIGHT = 320; private final int MIN = 20; // minimum picture size // references for the images private Image earth, flowers, pillars; public void init() { earth = getImage(getDocumentBase(), "gal_australia.jpg"); flowers = getImage(getDocumentBase(), "flowers_and_leaves.jpg"); pillars = getImage(getDocumentBase(), "hst_pillars_m16_close.jpg"); setSize(APPLET_WIDTH, APPLET_HEIGHT); } public void drawPictures(int size, Graphics panel) { panel.drawImage(earth, 0,size/2, size/2, size/2, this); panel.drawImage(flowers, size/2, 0, size/2, size/2, this); panel.drawImage(pillars, size/2, size/2, size/2, size/2, this); if (size > MIN) { drawPictures(size/2, panel); } } public void paint(Graphics panel) { drawPictures(APPLET_WIDTH, panel); } }