Introduction to Computer Science II by James Tam Return to the course web page

CPSC 233: Assignment 5 (Worth 8%)

 

Creating a simple graphical user interface

For this assignment you are to implement a simple GUI (graphical user interface) that allows a person to manage a list of contacts.  

The full program will read the information about the contacts from a text file called "contacts" and display this information in a list.  The user will have the ability to add a new contact or delete an existing contact.  When the user wants to quit the program by closing the window the updated contact list will be saved in a file called "updatedContacts".

 

Grading

 

Base grade levels

D-

Student has invested considerable effort in the assignment but the code won't compile.

D

Student has invested considerable effort in the assignment.  The program compiles but does not fulfill any of the requirements listed  below.

D+

Program is an "empty" GUI.  While you do not have to use one of the layout manager classes for this assignment, all the components are laid out neatly but none of the functionality has been implemented e.g., pressing a button does nothing.  

C-

The window can be closed by pressing the close window control.

C

Program reads the initial information for the list of contacts from a file called "contacts".  (You must use this file name otherwise your TA will have a hard time figuring out what name that you used making the marking that much harder).   The list of contacts will be displayed in the list.    Your program will automatically load in the list of contacts from file, there is no need to implement another control (such as a "load" button) to do this.

C+

As the window closes (as per the functionality implemented in the "C-" level assignment) the program will write the current contents of the list to a file which must be called "updatedContacts").

 

 

Additional features:

Implementing each of the features listed below will result in a grade increase of one letter "step" for each feature implemented for a maximum grade of A+.  Except for case #2, 5 & 6 you are free to implement the features in whatever order that you desire.

1

The user can remove contacts from the list by selecting it from the list and pressing the remove button.

2

When the list is empty, the remove button is disabled.  You must have implemented feature #1 prior to implementing this feature (so you can empty out the list).

3

Text that is entered into the text field will be added to the list as a contact when the add button is pressed.

4

Text that is entered into the text field will be added to the list as a contact when the user hits return when the cursor is in the text field.

5

The text label indicates to the user that a new contact was successfully added to the list ( feature #3 & 4 so they must be implemented prior to implementing this feature).

6

The program won't add "empty" contacts to the list.  If the text field doesn't contain any text when the add button is pressed or when the user hits return, then nothing will be added to the list.  Again this feature must be implemented after feature #3 & 4 has already been completed.

Other submission requirements

1. Good coding style and documentation:  They will play a role in determining your final grade for this assignment.  Your grade can be reduced by a letter step e.g., "A" to "A-" for poor programming style.

2. Method of submission: Do not hand in a paper typescript of this assignment.   Instead you must electronically submit all your source code before the due date.  There will not be a need to demo this assignment to your TA.   In addition to submitting your source that you include a file called "README".  This file must include all the pertinent information needed by your TA to mark your assignment:

Because there aren't any demos for this assignment, this file must be complete enough so that your TA can understand exactly how to run all parts of your program.

 

New Concepts to be applied for the assignment

How to implement a graphical interface with Java1:

  1. Frames
  2. Lists
  3. Classes that handle layout (e.g., GridBagLayout)
  4. Textfields
  5. Labels
  6. Buttons
  7. Listener classes (implements ActionListener)

File-based input and output:

  1. FileReader
  2. BufferedReader
  3. FileWriter
  4. PrintWriter

1While you are allowed to implement your assignment using either the classes in the newer Swing packages or the older AWT packages officially we will be providing support only for AWT.  That means that if are using SWING and get stuck then you may be one your own.

 

Relevant links

1) Sun's online AWT documentation: http://java.sun.com/j2se/1.4.2/docs/guide/awt/index.html.  Look especially at the packages: java.awt and java.awt.event.

2) Sun's online SWING documentation: http://java.sun.com/j2se/1.4.2/docs/guide/swing/index.html