import objectdraw.*; // a demonstration of counting up from zero // and showing the value in the window and the terminal public class Counter extends FrameWindowController { private static final Location TEXT_LOC = new Location(20, 30); private int counter = 0; private Text counterDisplay; public void begin() { // create the initial display in the program window counterDisplay = new Text("Counter value is " + counter + "!", TEXT_LOC, canvas); } public void onMousePress(Location point) { // equivalent to counter = counter + 1 counter++; // update the displayed text in the program window counterDisplay.setText("Counter value is " + counter + "!"); // print the counter value in the terminal window System.out.println("Counter value (terminal) is " + counter); // print a blank line System.out.println(); } }