// ImageApplet.java // Demonstrates displaying and scaling an image // Adapted from a program in Deitel&Deitel by cmc, 7/25/01 import java.awt.*; import javax.swing.*; public class ImageApplet extends JApplet { private Image cup; public void init() { cup = getImage(getDocumentBase(), "javacup.gif"); } public void paint( Graphics g ) { // draw the original image g.drawImage(cup, 0, 0, this); // draw the image again, scaled to fit the width of the applet // and the height of the applet minus 120 pixels g.drawImage(cup, 0, 120, getWidth(), getHeight()-120, this); } }