Computer Science 252
Problem Solving with Java
Spring 2014, The College of Saint Rose
TouchyWindow Demo
A working demo of TouchyWindow will appear below. Click inside the applet to interact with it.
TouchyWindow BlueJ Project
Click here to download a BlueJ project for TouchyWindow.
TouchyWindow Source Code
The Java source code for TouchyWindow is below. Click on a file name to download it.
import objectdraw.*; import java.awt.*; /* * A first Java/objectdraw example. * From Bruce, Danyluk, Murtagh, 2007, Chapter 1. * * $Id: TouchyWindow.java 2218 2013-10-18 14:06:39Z terescoj $ */ public class TouchyWindow extends WindowController { /* This method will execute when someone clicks on the window. It will result in a message being displayed. */ public void onMousePress(Location point) { new Text("I'm touched", 40, 50, canvas); } /* This method will execute when the mouse button is released. It will remove everything drawn in the window, which in this case can only be the text message displayed by the above. */ public void onMouseRelease(Location point) { canvas.clear(); } }