For this assignment, we will extend the Lab 1 windows project from a text-based version to a much more realistic graphic version. We will keep the basic behavior of the windows, however: you may want to use much of the code you wrote for that first lab—or you may want to re-write it from the perspective of new ideas and skills you have conquered since then.
More specifically, you should write a GUI-based program which will put up a simple graphic frame and allow the user to draw “windows” (really just rectangles for now) by clicking and dragging the mouse. You should also implement the window “promotion” feature from the first lab, so that of a user clicks without dragging on some window, then it gets promoted to the front of the window list. (Of course, if a window is completely obscured by a larger window in front, it won’t be promotable because the user won’t be able to click on it.)
You should try to design your application so that it is flexible, i.e., so that it can be extended to new circumstances and new features. Think about what sorts of changes might be made and try to anticipate them as much as possible. Consider carefully how the decisions you make now about the structure of your program will affect your ability to make changes later. Try to use techniques like interfaces, inheritance (sub-classes) and generics to make your code more flexible.
In order to write a GUI program that responds to mouse clicks, you’ll want to
Applet class as demonstrated in the sample mouse-based programs
in the example applet directory
(specifically, you might want to look at the
You should also have notes from lecture about how to do this, so check those as well.
You can get a sense of what your program should look like by looking at the graphic window-promotion sample program; note, however, that you are not required to implement title bars or close boxes! Of course, you may choose to implement these features (little grow handles in the lower right corners would be another nice touch!), but they are not required.
You may also find the following Java tutorials helpful in writing up a mouse-based applet: