Reference: Chapter 7 (Toolbars), and
Chapter 9 (Actions and Icons)
The assignment:
Modify the program of the previous assignment to:
(1) have a toolbar
that allows the user to select a shape to draw,
(2) define Actions that allow the user to select a shape
to draw - an oval (axis-aligned ellipse) or rectangle, filled or unfilled, and
(3) use your own oval and rectangle icons on the toolbar.
The interface should look something like:
+------------------------------------------------------+ | File Shape Color Help | +-------+----------------------------------------------+ |+-----+| | || +-+ || | || | | || | || +-+ || | || || | |+-----+| < blank area for drawing > | |+-----+| | || _ || | || / \ || | || \_/ || | || || | |+-----+| | +-------+----------------------------------------------+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 bottom button.
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 Repositor. Of course it needs to be unzipped and put in the jars subdirectory where ActionDemo program file is.
As mentioned in class, there are (at least) two ways to make your own icon:
FrameDemo2.java
Note: this program also needs the icon image
FD.jpg
to run.
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.