Computer Science 120
Introduction to Programming

Spring 2012, Siena College

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.


TouchyWindow.java

import objectdraw.*;
import java.awt.*;

/*
 * A first Java/objectdraw example.
 * From Bruce, Danyluk, Murtagh, 2007, Chapter 1.
 *
 * $Id: TouchyWindow.java 1479 2011-01-11 16:14:02Z 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();
    }
    
}