Data Structures—Window System Example

Here’s another example of a simple web-deployed applet; this one is a paint-based graphical version of our first lab, where we promoted a “clicked” window to the front of a list of windows. This version, in addition to being graphical, includes some enhancements to make it feel more realistic, namely close boxes and draggable title bars.

(The windowing style used here is reminiscent of old-school Macintosh windows of the pre-OS X days. The pastel colors are an homage to the original candy-colored iMacs. My wife says they look like sticky notes on the Mac … and they do! Perhaps I should add a text feature.)

To use the system, click on an inactive area to start drawing a window, dragging to the desired dimensions (they must be above a minimum 12-by-12). You should see a red rectangle while dragging, as a preview of the final window. “Active” areas include the close boxes and titles bars of existing windows, which can be used to close or re-position those windows. Clicks in the non-active areas of existing windows will promote them to the front of the window list, and they should be re-drawn that way. Currently the windows drag without promotion, which doesn’t reflect typical real-world window system behavior; there are also no draggable resizing controls on the sides or corners.

I am not releasing the source code to this project yet, as I may want to have you write something similar yourselves.