01: import java.awt.Graphics;
02: import java.awt.Graphics2D;
03: import java.awt.Rectangle;
04: import javax.swing.JApplet;
05: 
06: /**
07:    An applet that draws two rectangles.
08: */
09: 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: