COMP 440 Object-Oriented Programming in Java

Penn State Harrisburg - Spring 2007

Final Programming Assignment: Due May 1, 2007

60 points

Problem statement:

Many years ago-- before FaceBooks and MySpace-- schoolchildren enjoyed learning about each other by passing around "personality books." Personality books consisted of a sheaf of notebook paper having construction paper covers that were kept together by brass fasteners. Each page of the book contained a subjective question intended to evoke some insight as to a friend's personality. The books were passed from child to child, each one in turn writing answers to questions that appeared one to each page. A typical question would be "What is your favorite television program?" A participant would write his or her name followed by the answer, with perhaps an explanation, "Suzy - I like Gilligan's Island because I want to be just like Mrs. Thurston Howell when I grow up."

Suppose that a friend of yours, recognizing that this is a beneficial socialization activity, has asked you to help her construct a personality book for her niece. (Your friend would rather have her niece and her friends passing around custom designed text files than putting personal information on the Internet—another sign of the times.) Thus, the two of you have decided to create a computerized version using Java Swing.

You have decided upon a screen layout that is very nearly like the one shown in Figure 1.

Your task is to implement the behavior for this GUI. Specifically:

1. The user can save and retrieve his personality data through the File | Load and File | Save options on the menu bar.

2. The File | Exit option on the menu bar (and the Window frame "close" controls) will prompt the user to save any changed information before closing the window. (The user can decline this prompt.)

3. The Help option will display a brief message about the use of the screen. (You will need to create another component to do this!)

4. The background color for the top-level frame is R = 241 G = 241 B = 241. The other components and fonts may be of any contrasting colors (including letting them default to black).

5. All questions do not have to be answered. The user can save and retrieve (for editing) all entered information. To edit information, the user will enter his or her name in the name field. If a record is found on file that matches the name, the appropriate fields on the screen will be populated with whatever information has been entered and will invoke the correct behaviors on the components.

6. The behaviors of the buttons will be appropriate: Specifically, the question that asks about the favorite animal consists of a group of radio buttons. Only one of the radio buttons may be selected. If the "Other" option is selected, the JTextField for "Other" will be input-enabled, otherwise is will not be editable. The response to the question regarding pizza preference will display a happy pizza (happy.gif icon on the adjacent JLabel) or a sad pizza (sad.gif). The initial icon is empty.gif. All three gifs can be found in the finalicons.zip archive.

7. Fields for Name, Age, and "Other" favorite animal are JTextFields. The favorite sport JComboBox shall be populated with: Baseball, Football, Soccer, Ice Hockey, Fly Fishing, and Darts. The answer to the summer vacation question shall be written in a JTextArea that has allows a scrollbar only on the right hand side.

You do not have to use a layout manager for this screen. You can do so if you wish, but in the interest of time, you may elect not to do so. (To do this, you will probably need to place the questions inside various containers that would be placed in the layout. You might need containers within containers.)


Figure 1: Personality Book GUI Layout