/*
  Disegna un cerchio oppure un quadrato.
*/

import java.awt.*;

public class CerchioQuadrato extends java.applet.Applet {
  int cerchio=1;

  public boolean mouseDown(Event e, int x, int y) {
    Graphics g=getGraphics();
    
    if( (x>=10) && (x<=70) && (y>=10) && (y<=30) ) {
      g.clearRect(100,100,200,200);

      g.drawRect(150,150,100,100);

      cerchio=0;
    }

    if( (x>=10) && (x<=70) && (y>=50) && (y<=70) ) {
      g.clearRect(100,100,200,200);

      g.drawOval(150,150,100,100);

      cerchio=1;
    }

    return true;
  }

  public void paint(Graphics g) {
    g.drawRect(10,10,60,20);
    g.drawString("quadrato",15,25);

    g.drawRect(10,50,60,20);
    g.drawString("cerchio",15,65);

    if( cerchio==1 ) {
      g.drawOval(150,150,100,100);
    }
    else {
      g.drawRect(150,150,100,100);
    }
  }
}
