Moused Boxes

Due: Thursday, Jan. 23


Combine into a single class, MousedBoxes, the classes from Core Java, TestButton and MouseTest.  The MousedBoxes class should represent an applet. When submitting your program, make sure you submit both the .java code and an associated .html file with which to run your applet.

Program behavior specification:

The program should create a window containing five buttons at the top of the window, labelled "Red", "Blue", "Yellow", "Big", and "Small".  Conceptually, these buttons can be consided to be in two groups, "color" and "size".  Whenever the mouse is clicked in the area below the buttons, a filled rectangle should be drawn at that point (use Graphics.fillRect).   The rectangle's size and color shall be determined by the most recently clicked buttons.  Note that clicking on the buttons should not change the appearance of any rectangles already drawn.  Double-clicking on a rectangle shall delete the rectangle.  Clicking and dragging on a rectangle shall move it.

Deletion of a rectangle should not alter the appearance of any of the other rectangles. If a rectangle A was "on top of" (overlapped) rectangle B, then when rectangle C is deleted, A should remain on top of B.

Hints:

Be careful how you handle attempts to "drag" a rectangle into the "buttons" area of the window.  There are a couple of ways to handle this, one is to use two panels, instead of one: one to hold the buttons, the other for the rectangles.

Submitting Your Program:

Use the electronic submission system (caddis.acad.emich.edu/~hwmatt/student) to submit your file(s).  You must provide at least one file named MousedBoxes.java.