Overview of the application

In a real-world software application, you would ideally use a database to store personal information. In this application however, you will use a data file to store the information. For simplicity, only 5 attributes of a resident will be stored: resident name, room number, age, gender and the care level required.

In a typical session of the application, the resident data file will be loaded from the disk and displayed. The nursing home staff can then view, sort, search, as well as update the information. The updated information can be saved back to the file. This application is an exercise in text file processing, sorting and searching a list. As well, you get to create new GUI components such as the tabbed pane component.

The GUI

The GUI you will create should resemble the two screens shown below. See image. See image.

As you will note from the screens, the GUI has two tabs: Query Records and Update Records as shown in Figure 1 and Figure 2. The first screen is displayed when the Query Records tab is selected and the second is displayed when the Update Records tab is selected. The JTabbedPane component is used to create the two tabs. With tabbed panes, you can have several components such as panels that share the same screen space.

The GUI components on the first screen as shown in Figure 1 are as follows:

  • A label for the application title – Nursing Home Data Manager
  • The Query Records tab which contains the rest of the components on the screen namely:
    • A text area for displaying a list for resident data; and
    • A panel containing 4 buttons and 1 text field.

The GUI components on the second screen as shown in Figure 2 are as follows:

  • A label for the application title – which is the same one as in the first screen since it is outside of the tabbed panes.
  • The Update Records tab which contains the rest of the components on the screen namely:
    • A panel containing 2 text fields and their corresponding labels, 3 JCombobox components and their corresponding labels;
    • A panel containing a text area for displaying the resident data. This text area is different from the one in the Query Records tab; and
    • A panel containing 5 buttons.

Some details of how the program functions

  • In a typical session of the application, the Query Records tab is selected by default. Normally the first action is to load the file by clicking the ‘Load’ button. The content of the loaded file is displayed on both the Query Records tab text area and the Update Records tab text area. Below is the typical screen when the file is first loaded (Figure 3). Note that if the data were not loaded but the ‘Sort’ button is pressed, a message like “Data to be loaded” should be displayed on the text area. See image.
  • Here is the screen on which the list is sorted by name when the ‘Sort’ button is pressed. Note: Use any of the sorting algorithms covered in this course to sort the list. We would like to recommend you using the resident class with implementation of Comparable interface so that two resident objects can be easily compared by their names. You can use built-in sort algorithms from java package. See image.
  • The ‘Search’ text field requires entering a resident name regardless of lower case or upper case spelling and then clicking the “Enter” key on the keyboard as shown in Figure 5a. If the resident name exists in the list, the corresponding information of this resident is display on the text area as shown in Figure 5b; otherwise the message – “No result found” is displayed on the text area. See image. See image.
  • Now switching to the Update Records tab, here is the screen when the information for a new resident has been added to the list and displayed as shown in Figure 6a (before the ‘Update’ button is pressed.) and Figure 6b (After the ‘Update’ button is clicked, where the text fields and JCombobox are required to return to the initial default status.). See image. See image.
  • When the ‘Update’ button is clicked, the program must first validate the resident information entered – the name input can be any string except blank but the room number must be a combination of a letter (at the beginning) plus 3 digits (like A380). If the resident is already in the list, then only his/her room number, and care level can be updated. Otherwise a new resident entry with all the information is created, added to the list and then displayed. The program needs to search by the resident name to determine whether or not a resident entry exists.
  • The ‘Delete’ button requires entering a resident name to be deleted from the list via the name text field as shown in Figure 7a. After clicking the ‘Delete’ button, the patient data (if existed) is removed with the confirmation message as Figure 7b. If the entered resident name is not existed in the list, a message box with the content “Resident name not found” pops out. See image.
  • The ‘Save’ button saves the updated list to the file. A confirmation message should be given to the user if the old file is successfully overwritten with the updated one. See image.
  • The ‘Clear’ button in each tabbed pane clears the text area in that pane. And the Exit button in both panes terminates the program.
  • Important: Structure your program by using helper methods. The main technique is to identify the main tasks and then break these down to small manageable tasks that can be translated easily into suitable named methods.

Data storage structures

  • A text file called Resident.txt will be used to store the resident information. This file will be made available to you on the course website.
  • The resident list is loaded from file into a Linkedlist or Arraylist of Resident objects. For this you will need the Resident class file - Resident.java. For convenient comparison of Resident objects, we suggest you to implement Comparable interface based on comparison of the resident name for this class.
  • The Resident class should declare suitable variables to store resident name, age, gender, room number and the care level and then only defines relevant get, set, toString( ) methods. ResidentManager class contains the implementation of GUI, event-handling, data file reading and writing, and other necessary methods.
  • Use meaningful variable names to store all values required in the application.
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.