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

import java.awt.event.*;

public class Rect3 extends JFrame {


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


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


}



class CCanvas extends Canvas {

 public void paint (Graphics g)
  {
    int x0, y0;  // Mittelpunkt
    int x, y;      // Mittelpunkt  links / oben
    int w, h;     // Breite Höhe
    int diff;
    x0 = 150;
    y0 = 150;
    diff = 10;
    w = 50;
    h = 50;

    g.setColor(Color.blue);
    for (int i=0; i<10; i++) {
      g.drawRect(x0,y0,w,h);
      x0 -= diff;
      y0 -= diff;
      h += diff << 1;  //SHL 1;
      w += diff*2;
      g.setColor(Color.red);
    }  // for

  }


}

