CS 3291 (Java with Internet Applications):
Homework #5

Assigned:
????

Due:
????

Credit:
10 points.

Objective:
(1) Modify a program that uses the AWT classes to work with graphical objects, and (2) convert an application to an applet.

Description:
For this program, you are given a stand-alone Java application program. You are to make one enhancement to its behavior (as described) and convert it to an applet.

In its current form, the program displays:

What you are to add is:

See the "before" and "after" pictures in the Detailed description below.

You are also to convert the program into an applet, to be executed via the command:

appletviewer PolyDrawApplet.html
(You will be given the HTML file PolyDrawApplet.html.)

Instructions:
  1. Review the Detailed description and Helpful hints sections below.
  2. Download the initial program PolyDraw.java. Also download CloseableFrame.java (you will not need this class for your applet, but will need it to run the initial program).
  3. Download the required HTML file PolyDrawApplet.html. (Note that to display or download this file you will probably need to use your browser's "display source" option.)
  4. Modify the program as needed, producing a PolyDrawApplet class (in a PolyDrawApplet.java file).
  5. Test the program until you are satisfied that it works.
  6. Submit your Java source file, as described in How to submit homework. You need only submit PolyDrawApplet.java, not PolyDrawApplet.html.

Helpful hints:

Detailed description:

Current user interface:
The initial program's interface looks like this (under Unix/X -- should look similar though maybe not identical under Windows). (Here, the user has drawn one polygon, the black triangle, and is in the process of drawing a second polygon in blue.)

Desired user interface:
Your applet's interface should look like this (using the JDK appletviewer under Unix/X -- should look similar though maybe not identical under Windows). (As in the previous illustration, here the user has drawn one polygon, the black triangle, and is in the process of drawing a second polygon in blue.)

The value displayed in the label at the top of the panel should reflect the total number of "completed" polygons -- that is, it should change when (1) the user clicks the right mouse button to "finish" a polygon, and (2) when the user presses the clear button to reset everything.

Grading:
This homework is worth 10 points: