CIS 068 / 2: Lab-Assignment #4: The Magical Sketchpad
The Magical Sketchpad consists of two windows:
- The control or input - window
- The output - window
The control window provides a sketchpad, some control-boxes and a button.
The output window consists of four square panels, composed in a way to build one
big square area.
Every mouse movement that occurs inside the sketchpad of the control window is transferred
to each of the 4 output panels, forcing them to draw a circle at the specified position
(see figure above). Therefore it is possible to draw sketches in the output-area by moving
the mouse over the sketchpad.
The controls influence the output in the following way:
Each of the 4 output areas is assigned to 3 checkboxes:
- draw: if unchecked: don't draw on specified area
- flip horizontally: change the outputs x-coordinate (flip left and right)
- flip vertically: change the outputs y-coordinate (flip up and down)
The control window's button erases (or cleans) the window of all 4 output-areas.
click here to see the program as an applet.
Circles are drawn pressing (and holding) the left mouse-button while moving the mouse over
the blue sketchpad.
Your browser must support javax.swing.
Some hints:
- The easiest way to create the two basic windows is to create instances of JFrame (or derived
own classes, if required by your design)
- The input-window's layout should be a BorderLayout, adding the sketchpad into the center, the
controls into the west, the erase-button into the south.
- The controls should be collected in their own JPane, using a GridLayout.
- The output-window should use a 2 x 2 GridLayout
You might have recognized, that this assignment deals with GUI-elements and events. Think about the question,
which elements are event-sources, which elements are listeners !
More help will be added to this page after collecting some questions.