import objectdraw.*; import java.awt.*; // A program to detect when two consecutive mouse clicks // occur at exactly the same canvas coordinates public class SteadyTester extends FrameWindowController { // where to display the word private static final Location MESSAGE_LOCATION = new Location(100, 100); private static final int FONT_SIZE = 24; // Text of the message private Text steadyMessage; // Last position clicked on private Location lastPoint = new Location(-1, -1); // Create the message public void begin() { steadyMessage = new Text("click!", MESSAGE_LOCATION, canvas); steadyMessage.setFontSize(FONT_SIZE); } // Display "STAYED" if location of click has not changed public void onMouseClick(Location point) { // Need to test that the points are the same if (point.equals(lastPoint)) { steadyMessage.setText("STAYED"); } else { steadyMessage.setText("MOVED"); } lastPoint = point; } }