CS 338: Graphical User Interfaces

Assignment 2

Due Sunday, February 1


This assignment asks you to build a realistic multi-window user interface that combines concepts of basic Swing programming with additional concepts of design guidelines and graphics.

Problem  (10 pts)

Write a program "SimpleDraw" that allows a user to draw basic shapes on a canvas. The system provides a way for the user to enter parameters of basic shapes, maintain a list of such shapes, and display all shapes on an electronic canvas. Your program should allow for the input of the following shapes:

All fields are required, and the program must check to see that the fields are not empty, and also that the numerical fields are integers. The "fill" information should be displayed with a check box. The "color" information should be a JComboBox with 5 options: black, blue, green, red, & yellow (please use the colors in the java Color class for these options).

Your system should be a multi-window application as follows. The main window (JFrame) should contain two main components: (1) a list of all shapes currently in the system, and (2) a graphics panel where all shapes are drawn. The list should be a JList where each line of the list is the text representation of the shape -- the text should match the examples above under each shape-field listing. The graphics panel should be a standard JPanel with a size (500,500), overriden such that the shapes in the list are drawn on the panel. Obviously, the positions, sizes, fills, and colors of each shape should be drawn correctly.

Also under the main list, there should be three buttons (like in A1): Add, Change, and Remove. When the user clicks Add, a new window (JDialog) should pop up with a tabbed pane with the various shapes (again like A1) as well as OK/Cancel buttons; if the user enters information and clicks OK, this shape is added to the list in the main window, but if the user clicks Cancel, the shape is not added. Similarly, the Change button pops up a new window where the current shape information is filled into the fields, allowing the using to change the information (with OK) or cancel the changes (with Cancel). The Remove button simply removes the shape from the list. In all cases, as soon as the shapes in the list are changed, the graphics panel should be redrawn to display the changes.

As in A1, you should not load any information from a file (or database) on startup or save the information upon quitting. Please ensure that the list is initially empty on startup of the program. You should also use proper object-oriented programming whenever possible, particularly in the classes that represent the shapes.

Your main class must be called "SimpleDraw" such that the program can be started by typing:

    java SimpleDraw

[One final note: The Color.toString() method gives debugging output, not the actual name of the color; here is a class ColorUtility.java which you may incorporate if you find it useful.]


It is expected that all code written for this assignment is properly commented. Please document each function you write/modify, especially in places where you have made particular choices about data structures and/or algorithms to employ. Also, please add an identification header to every file with the following format:
     * [Your Name]
     * [Your-Email]
     * CS338:GUI, Assignment [#], Program [#]


The assignment should be submitted on WebCT in a single zip or tar file.


The grading for your program will break down roughly as follows: