import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;

public class Counter
	extends Applet
	implements ActionListener {

  // Common "state" variables
  private Button upButton = new Button("Add 1");
  private int counter = 0;
  
  // Set up GUI
  public void init() {
    add(upButton);
    upButton.addActionListener(this);
  }
  
  // Display current count
  public void paint( Graphics g ) {
    g.drawString("Count: "+counter, 70, 50 );
  }
  
  // Respond to button clicks
  public void actionPerformed(ActionEvent e) { 
    // Must be an "Add 1" button click
    counter = counter+1;
    repaint();
  }
}