// CS 134 demo program to keep track of number of clicks
import objectdraw.*;
import java.awt.*;
public class ClickCounter extends WindowController {
private static final int DISPLAY_X = 150; // coords of display start
private static final int DISPLAY_Y = 200;
private Text display; // display of number of clicks
private int count; // count of number of clicks
// Initialize count and Text on screen
public void begin()
{
count = 0;
display = new Text("Click count = 0", DISPLAY_X, DISPLAY_Y, canvas);
}
// Each time click, increase count and display
public void onMouseClick(Location point)
{
count = count + 1;
display.setText("Click count = " + count );
}
}