  //The Canvas Applet that generates random colour circles

  import java.awt.*;
  import java.awt.event.*;
  import java.applet.*;
	
	
  public class CanvasApplet extends Applet implements ActionListener
  {
    MyCanvas c;
		
    public void init()
    {
	Button b = new Button("Randomize!");
	b.addActionListener(this);

	c = new MyCanvas();

	this.setLayout(new BorderLayout());
	this.add("North", b);
	this.add("Center",this.c);
    }

    public void actionPerformed(ActionEvent e)
    {
	c.drawCircles();
    }

  }
	
	
  class MyCanvas extends Canvas
  {
     Color tempColor;

     public void drawCircles()
     {
	this.repaint();
     }

     public void paint(Graphics g)
     {
	for(int i=0; i<200; i++)
	{
	  tempColor = new Color((float)Math.random(),(float)Math.random(),(float)Math.random());
	  g.setColor(tempColor);
	  g.drawOval((int)(Math.random()*200), (int)(Math.random()*200), 20, 20);
	}
     }
  }
