import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;

public class RandRect extends JFrame {
	public RandRect() {
		super("Cascading Rectangles");
		setSize(700, 400);
		//setBackground(Color.red);
				show();
	}
	public void paint(Graphics g){
		int a = 0, b = 0, n = 0;
		g.setColor(Color.white);
      	g.fillRect(0,0,700,400);
		while(n <= 100){
			a = (int)(Math.random() * 650);
			b = (int)(Math.random() * 350);
			g.setColor(new Color((int)(Math.random() * 256), (int)(Math.random() * 256), (int)(Math.random() * 256)));
			try { Thread.sleep( 300 );} catch (Exception e) {}
			g.fillRect(a, b, 90, 55);
			n++; //a += 50; b += 25;
		}
	}


	public static void main(String args[]){
		RandRect app = new RandRect();
		app.addWindowListener(
			new WindowAdapter(){
				public void WindowClosing(WindowEvent e){
					System.exit(0);
				}
			}
		);
	}
}
