import javax.swing.*;
import java.awt.*;
import java.util.Random;
public class FLWPainting extends JFrame
{
public int x=0, y=0, width=0, height=0, red=0, green=0, blue =0;
public Random myGen = new Random();
public int calls = 0;
public int size = 800;

public FLWPainting()
   {
   setSize( size, size );
   setLocation( 10, 10 );
   setBackground( Color.white );
   setVisible( true );
   setDefaultCloseOperation( EXIT_ON_CLOSE );
   } // end constructor

// "paint" is a method already in JFrame
// it's called automajically by the computer
// it uses the Graphics helper class
// I'm rewriting it
// That's called over-riding 
public void paint( Graphics g )
   {
   calls = calls + 1;
   System.out.println( calls );
 
   g.setColor( Color.white );
   g.fillRect(0, 0, size, size);

  while (true )
      {
      x = myGen.nextInt( size ); // 0 thru 400 
      y = myGen.nextInt( size );
      width = myGen.nextInt( 101 ); // 0 thru 100
      height = myGen.nextInt( 101 );    
      red = myGen.nextInt( 256 ); // 0 thru 255 
      green = myGen.nextInt( 256 );
      blue = myGen.nextInt( 256 );

      g.setColor(  new Color( red, green, blue )  );
      g.fillOval( x, y, width, height );

      x = myGen.nextInt( size ); // 0 thru 400 
      y = myGen.nextInt( size );
      width = myGen.nextInt( 101 ); // 0 thru 100
      height = myGen.nextInt( 101 );    
      red = myGen.nextInt( 256 ); // 0 thru 255 
      green = myGen.nextInt( 256 );
      blue = myGen.nextInt( 256 );

      g.setColor(  new Color( red, green, blue )  );
      g.fillRect( x, y, width, height );

      x = myGen.nextInt( size ); // 0 thru 400 
      y = myGen.nextInt( size );
      height = myGen.nextInt( 101 );    

      g.setColor( Color.black );
      g.fillRect( x, y, 4, height );

      x = myGen.nextInt( size ); // 0 thru 400 
      y = myGen.nextInt( size );
      width = myGen.nextInt( 101 );    

      g.setColor( Color.black );
      g.fillRect( x, y, width, 4 );



      } // end for 
   } // end paint 

public static void main(String args [] )
   {
   new FLWPainting();
   }

} // end class