CSC 112
Ileana Streinu

4. Button with action

  1. Modify the applet so that it counts how many times the button was clicked, and prints that number on the Java console after each click. You will have to declare a class variable of type int, initialize it with zero in init and increment it each time the button is pressed (in actionPerformed.

  2. Modify the applet to have three buttons: Start, Increment and Stop. When Start is pressed, a counter is initialized with zero. When Increment is pressed, the counter is incremented. When Stop is pressed, the value of the counter is printed on the Java console and on the applet.