/* 
       Import all matching classes: the standard Applet and Abstract Window
       Toolkit classes.
*/

import java.applet.*;
import java.awt.*;

/*
      Declare class "clickcount" as a subclass of class "Applet"
*/
public class clickcount extends Applet
{ /* start class clickcount */
  int count ;
  TextField f;

      /*
            This code builds the display of the applet (Figure  37.3)
	    It redefines "init"
      */
  public void init ()
  { /* start init */
    count = 0;
       /*
             Create an instance of "Button" and add it to the applet's
	     window.
       */
    add(new Button ("Click Here") );
    f = new TextField ("   The button has not been clicked at all.");
    f.setEditable(false);
    add(f);  /* Associate f with the applet window. */
  } /* stop init  */

      /*
            This code redefines "action."  It determines the action performed
	    when the user clicks on the button.
      */
  public boolean action (Event e, Object arg) 
  { /* start action  */
     if ( ( (Button) e.target).getLabel() == "Click Here")
     {/* start if  */
        count += 1;
        f.setText ("     The button has been clicked " + count + " times.");
     }/* stop if  */
     return true;
  } /* stop action  */

}/* stop class clickcount */
