Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java: student directory GUI You need to implement three classes: Person Student StudentDirectory StudentMain Start by implementing Person and Student classes. Once you are sure

Java: student directory GUI

You need to implement three classes:

Person

Student

StudentDirectory

StudentMain

Start by implementing Person and Student classes. Once you are sure you can serialize and deserialize and ArrayList of Students to and from a file, move on to building the GUI application.

Person:

The Person class should implement serializable interface. It contains the following:

Person's first name (String)

Person's last name (String)

Person's id number

Person's date of birth (Date)

public String toString(): This method method should return the following string (without ) for a person with id=1111, firstName="Joe", lastName="Smith", dob="01-25-1990": 1111 Joe Smith 01-25-1990

The Person class should implement all getter and setter methods for these data members.

Student:

The Student class is a subclass of Person, it should implement serializable. Student will have to employ custom serialization. That is, it needs to implement storeObject(...) and retrieveObject(...) methods (see below), and Person needs to have a 0-param constructor.

Student's college (String)

public void storeObject(ObjectOutputStream out) throws IOException

public Student retrieveObject(ObjectInputStream in) throws IOException, ClassNotFoundException

public String toString() method: This method is to add college name (in brackets) to the result of Person.toString() . So, for the above example if "Joe Smith" is a student at "Art&Sci" college. The output of the toString method should be: 1111 Joe Smith 01-25-1990 [Art&Sci]

StudentDirectory:

The StudentDirectory class is a GUI program that is used for retrieving/storing an ArrayList of Students from/to the file named "StudentsList.dat" using the serialization mechanism. StudentDirectory is a subclass of JFrame. It has a menu, and a few labels, textboxes, and buttons as described below:

Initially when executed, your program should load the ArrayList of Students into memory (you should implement a method for this purpose (i.e. loading) since this functionality is needed later as well). You can do this in the constructor of StudentDirectory. Then your program should show the information of the first Student of the ArrayList as described below. The very first time you run the program, there is no "StudentsList.dat" file. Your program should start as if the "Append" button is clicked (see below).

Your program should have a "File" menu with three menu-items: "Load", "Save", "Exit".

"Load" loads the ArrayList of Students from the above file into memory.

"Save" saves the ArrayList of Students into the above file.

"Exit" terminates the program.

For each attribute of the Student class, including the ones that are defined in Person, you need to have a textbox with an appropriate label preceding it.

For "dob" you can use three comboboxes to let user pick month, day, and year.

You also need a label to show the index of the current Student in the ArrayList.

You also need three buttons at the bottom of your frame: Previous, Next, Append.

The "Previous" button goes back to the preceding Student in the ArrayList. This button should be disabled if we are at the beginning of the ArrayList.

The "Next" button shows the succeeding Student in the ArrayList. This button should be disabled if we are at the end of the ArrayList.

Hitting the "Append" button clears all the textboxes and lets user enter information for a new Student. Also, the text on the "Append" button should change to "Submit". Once the user entered the information, he can press "Submit" to append the Student to the ArrayList. If he decided he does not want to do so, he can simply hit "Previous" to cancel changes and go to the last Student in the list.

Automatically save the ArrayList to file when the frame is closed.

StudentMain:

The StudentMain class is the program with the main method where you need to create your JFrame (i.e. StudentDirectoy) object and display it.

Things to note:

Your program should not crash due to any exceptions. However, in case of IOExceptions you can gracefully terminate your program and inform the user of the problem by showing an informative dialog box (use JOptionPane for this, the following is an example).

 //custom title, error icon JOptionPane.showMessageDialog(frame, "Eggs are not supposed to be green.", "Inane error", JOptionPane.ERROR_MESSAGE); 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

App creation software can only create games for the iPhone.

Answered: 1 week ago

Question

=+4 How does one acquire a global mindset?

Answered: 1 week ago

Question

=+2 How can the effectiveness of global virtual teams be improved?

Answered: 1 week ago