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

import java.awt.event.*;

public class Rect1 extends JFrame {


  public Rect1(String caption) {
    setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    setTitle(caption);
    this.getContentPane().add( new CCanvas(), 
       BorderLayout.CENTER );
  }

 



    public static void main(String args[]) {
      Rect1 f = new Rect1("Rect1");
     	f.setSize(500,400);
    	f.setVisible(true);
    }


}



class CCanvas extends Canvas {

 public void paint (Graphics g)
  {
    int x, y;  // Mittelpunkt
    int w, h;  // Breite Höhe

	g.setColor(Color.white);
     g.fillRect(0,0,
         getWidth(), getHeight() ); 
	g.setColor(Color.blue);
    System.out.println("in paint");
    for (int i=0; i<10; i++) {
      x = (int) (  400*Math.random() );	// Links Oben
      y = (int) (  200*Math.random() );	 // Links Oben
      w = (int) (  400*Math.random() );	// Width
      h = (int) (  200*Math.random() );	// Height
      g.drawRect(x,y,w,h);
    }
  }


}

