import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import javax.swing.JApplet;

/**
   An applet that draws two rectangles.
*/
public class RectangleApplet extends JApplet
{
   public void paint(Graphics g)
   {
      // Prepare for extended graphics
      Graphics2D g2 = (Graphics2D) g;

      // Construct a rectangle and draw it
      Rectangle box = new Rectangle(5, 10, 20, 30);
      g2.draw(box);

	  for(int i=0; i<1000; i++)
	  {
		  int x = (int)(Math.random()*300);
		  int y = (int)(Math.random()*400);

		  // Move rectangle 15 units to the right and 25 units down
		  box.setLocation(x, y);

		  // Draw moved rectangle
		  g2.draw(box);
	  }
   }
}

