Source Code:
import objectdraw.*;
import java.awt.*;
/**
* Demonstrates event-handling. When the mouse is pressed in the window
* a text box is created that says "I'm touched". The window is cleared
* when the mouse is released.
*
* Lisa Ballesteros adapted from Java: An Eventful Approach
*
*/
public class TouchyWindow extends WindowController {
public void onMousePress ( Location point ) {
new Text("I’m touched", 40, 50, canvas );
}
public void onMouseRelease( Location point ) {
canvas.clear();
}
}