1  import java.awt.Graphics;
  2  import java.awt.Graphics2D;
  3  import java.awt.Rectangle;
  4  import javax.swing.JApplet;
  5  
  6  /*
  7     An applet that draws two rectangles.
  8  */
  9  public class RectangleApplet extends JApplet
 10  {  
 11     public void paint(Graphics g)
 12     {  
 13        // Prepare for extended graphics
 14        Graphics2D g2 = (Graphics2D) g;
 15  
 16        // Construct a rectangle and draw it
 17        Rectangle box = new Rectangle(5, 10, 20, 30);
 18        g2.draw(box);
 19  
 20        // Move rectangle 15 units to the right and 25 units down
 21        box.translate(15, 25);
 22  
 23        // Draw moved rectangle
 24        g2.draw(box);
 25     }
 26  }
 27