home *** CD-ROM | disk | FTP | other *** search
/ Java by Example / jbecd.bin / JBE-CD / NTUsers / JBECODE.ZIP / JavaByExample / chap27 / ImageApplet.java < prev    next >
Encoding:
Java Source  |  1996-03-14  |  535 b   |  25 lines

  1. import java.awt.*;
  2. import java.applet.*;
  3. import java.net.*;
  4.  
  5. public class ImageApplet extends Applet
  6. {
  7.     Image snake;
  8.  
  9.     public void init()
  10.     {
  11.         URL codeBase = getCodeBase();
  12.         snake = getImage(codeBase, "snake.gif");
  13.         resize(250, 250);
  14.     }
  15.  
  16.     public void paint(Graphics g)
  17.     {
  18.         int width = snake.getWidth(this);
  19.         int height = snake.getHeight(this);
  20.         g.drawRect(52, 52, width+10, height+10);
  21.         g.drawImage(snake, 57, 57, width, height, this);
  22.     }
  23. }
  24.  
  25.