Lab Assignment 8 -- Demo and Writeup Due Nov. 1 in the lab session
CS 5551, Fall Semester, 2012
15 Points
Topics: Toolbars, Actions, Icons

Reference: Chapter 3 (Icons), Chapter 7 (Toolbars), and Chapter 9 (Actions)

The assignment: Modify the program of the previous assignment to:
(1) have a toolbar that allows the user to select a shape to draw, and color
(2) define Actions that allow the user to select a shape to draw - an oval (axis-aligned ellipse) or rectangle, filled or unfilled, its color, and
(3) use your own oval and rectangle icons on the toolbar.
The interface should look something like:

+------------------------------------------------------+
| File  Shape  Color                              Help |
+-------+----------------------------------------------+
|+-----+|                                              |
|| +-+ ||                                              |
|| | | ||                                              |
|| +-+ ||                                              |
||     ||                                              |
|+-----+|                                              |
|+-----+|                                              |
||  _  ||                                              |
|| / \ ||                                              |
|| \_/ ||                                              |
||     ||                                              |
|+-----+|                                              |
|       |                                              |
|+-----+|                                              |
||fil o||      < blank area for drawing >              |
|+-----+|                                              |
|+-----+|                                              |
||unf o||                                              |
|+-----+|                                              |
|       |                                              |
|+-----+|                                              |
||red o||                                              |
|+-----+|                                              |
|+-----+|                                              |
||grn o||                                              |
|+-----+|                                              |
|+-----+|                                              |
||blu o||                                              |
|+-----+|                                              |
+-------+----------------------------------------------+
Where the figure on the left is supposed to be a toolbar with a rectangle icon on the top button and an oval icon on the next button, a separator, radio buttons to choose filled or unfilled, a separator, and radio buttons to choose the color.

Discussion: some useful code is in the ActionDemo program, which illustrates both Actions and the use of a toolbar. Here is the ActionDemo program file. Note that if you want to compile and use this program with the arrow icons, you also need to download the jlfgr-1_0.jar file. A zipped version of it can be downloaded from the Java look and feel Graphics Repository. Of course it needs to be unzipped and put in the jars subdirectory where ActionDemo program file is.

In class, we discussed how to make your own icon (in How to Use Icons), this was shown as a special "Missing Icon" class, MissingIcon.java, but not as part of an application. There is another example of a custom icon (implemented the same way) that implements an "arrow" icon (pointing either direction) at: ArrowIcon.java. It is used in the CustomIconDemo.java application (which also needs the middle.gif file.

What to turn in: Turn in the following items from the Computer Science Lab Report Format:
1. (1 point) The Basic Information (your name, class, section, TA's name, assignment number, and date) can be on a separate cover sheet or as (highlighted) comments at the top of your main program file.
11. (5 points) Include the program listings. This listing should show good style, be appropriately commented, have the important/new parts highlighted, and include handwritten explanations if it helps the reader's understanding of the code.
13./14. (9 points) Do a demo of your modified program for the TA that demonstrates that the program works correctly.


Page URL: http://www.d.umn.edu /~ddunham/cs5551f12/assignments/lab8/assignment.html
Page Author: Doug Dunham
Last Modified: Thursday, 01-Nov-2012 11:09:12 CDT
Comments to: ddunham@d.umn.edu