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

CPSC 219: Assignment 6

Due: April 13 at 4 PM.

New concepts to be applied in this assignment (Using the following classes to implement a GUI and file input-output)

  1. JFrames
  2. JLists
  3. Classes that handle layout (e.g., GridBagLayout)
  4. JTextfields
  5. JLabels
  6. JButtons
  7. Listener interfaces and classes (e.g., ones that implement ActionListener or extend WindowAdaptor)
  8. FileReader
  9. BufferedReader
  10. FileWriter
  11. PrintWriter

Introduction

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

 

Resource file

 

The information for the list of contacts will be  loaded from file and added to the list as the program is run. The user can add new contacts or remove existing ones. The information for a new contact will be entered in the input field (beside  add button). The program will provide information to the user about its state (e.g., adding a new contact) or when errors have occurred (e.g., a new contact will not be added when the input field is empty). To simplify the marking of assignments make sure that you use the exact file names specified below). When the user closes the window the updated information for the contacts will automatically be saved to file.

Features

  1. When the program is run it will display the window which contains the graphical controls (2 labels, 2 buttons, a list and a text field) and those controls are laid out roughly the same fashion as shown in the picture.
  2. The program automatically loads the list of contacts from the file "contacts.txt" when the program is run. A try-catch block must be used when a method is called that can throw an exception.
  3. The program automatically saves the list of contacts to the file "updated_contacts.txt" when the window is closed. A try-catch block must be used when a method is called that can throw an exception.
  4. The user can remove a contact from the list by selecting the contact and pressing the remove button.
  5. Text that is entered into the text field will be added to the end of the list  when the add button is pressed.
  6. Text that is entered into the text field will be added to the end of the list when the cursor (focus) is in the text field and the user hits enter.
  7. The title bar of the frame indicates to the user when an existing contact was removed (the remove feature must be implemented first). The message in the title bar will remain for a few moments and then the text in the title bar will revert back to what was originally there. Because you won't have learned how to create threads, the interface will "lock" during this period of time and will not accept any input from the user.
  8. Similar to the previous feature the title bar of the frame will temporarily display a status message when a new contact is added to the list (one or both of the add features must be implemented first).
  9. A status message will appear in the title bar when the close window control is used to shut down the program.
  10. The program won't add an empty contact to the list (input field empty) and in such cases it will display an error message in the title bar.
  11. One or more of the 'layout' classes are used to manage the layout and your program roughly looks like the one in the picture.

Submitting your work:

  1. Assignments (source code/'dot-java' files and a short README file listing which of the above features that you completed) must be electronically submitted according to [the assignment submission requirements].
  2. As a reminder, you are not allowed to work in groups for this class. Copying the work of another student will be regarded as academic misconduct (cheating).  For additional details about what is and is not okay for this class please refer to the following [link].
  3. Before you submit your assignment to help make sure that you haven't missed anything here is a [checklist] of items to be used in marking.

External libraries that can be used

  1. GUI widget classes for the graphical components.
  2. Listener classes and interfaces to react to events.
  3. Classes for file input and output (as well as the corresponding exception classes).