import javax.swing.*; 
import java.awt.*;
import java.util.*;

class Two extends JFrame {
  Two() {
    Three three = new Three(15);
    this.getContentPane().add( three ); 
    this.setVisible(true); 
    this.setSize(400, 500); 
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);     
  }
  public static void main(String[] args) {
    JFrame t = new Two(); 
  }
}

class Point {
  int x, y;
  Point(int x, int y) {
    this.x = x; 
    this.y = y; 
  }
}

class Rectangle {
  Point topLeft; 
  Color color; 
  int width, height; 
  Rectangle(Point location, int w, int h, Color c) {
    this.topLeft = location; 
    this.width = w;
    this.height = h; 
    this.color = c;
  } 
  void draw(Graphics g) {
    g.setColor(this.color);
    g.fillRect(this.topLeft.x, this.topLeft.y, this.width, this.height);
    g.setColor(Color.BLACK);
    g.drawRect(this.topLeft.x, this.topLeft.y, this.width, this.height);

  }
  boolean contains(Point where) {
    int dx = where.x - topLeft.x; 
    int dy = where.y - topLeft.y; 
    return 0 <= dx && dx < this.width && 0 <= dy && dy <= this.height; 
  }
  void moveTo(Point where) {
    this.topLeft = where; 
  }
}

class Three extends JComponent implements MouseListener, MouseMotionListener {
  public void mouseMoved(MouseEvent e) { } 
  public void mouseDragged(MouseEvent e) { } 
  public void mouseClicked(MouseEvent e) { } 
  public void mousePressed(MouseEvent e) { } 
  public void mouseReleased(MouseEvent e) { } 
  public void mouseEntered(MouseEvent e) { } 
  public void mouseExited(MouseEvent e) { } 
  ArrayList<Rectangle> shapes; 
  Three(int size) {
    this.shapes = new ArrayList<Rectangle>(); 
    for (int i = 0; i < size; i++) {
      Point where = new Point((int)(Math.random() * 300 + 50), 
                              (int)(Math.random() * 300 + 50)); 
      int width = (int)(Math.random() * 80 + 20);
      int height = (int)(Math.random() * 80 + 20); 
      int red = (int) (Math.random() * 255); 
      int green = (int) (Math.random() * 255); 
      int blue = (int) (Math.random() * 255); 
      Color color = new Color(red, green, blue);
      this.shapes.add(new Rectangle(where, width, height, color)); 
    } 
  }  
  public void paintComponent(Graphics g) {
    for (Rectangle r : this.shapes) 
      r.draw( g ); 
  } 
}