asked 161k views
2 votes
ADVANCED JAVA

You will write a Java application that maintains a file of
Persons (and their children).
File Menu
New
Open...
Save
Save as...
Exit
As always, a menu option with ... opens a dialog. You

1 Answer

6 votes

ADVANCED JAVA

You will write a Java application that maintains a file of Persons (and their children).

File Menu

New

Open...

Save

Save as...

Exit

As always, a menu option with ... opens a dialog. You already know how to save and load files of objects from the Serialization assignment; here you just invoke that code from the menu. All load and save dialogs should use the Java file chooser.

Help Menu

Display help options.

Other Menu Items as you deem necessary.

The main panel will show the current list of Persons, and will allow you to delete an existing Person from the list, or create a new Person (or subtype) from an existing Person or subtype. Use GUI controls and fields as you see fit. Note that the "Save" and "Save as..." options should be disabled while a Person is under construction (in other words, don't let them save until the job is done).

When entering a date, if that date throws an OCCCDateException display a pop-up ("Invalid Date!") and clear the date field so that they can try again. We already know that you can make an OCCCDate from pretty much any three integers, but we don't want to allow this as the error might just be an accidental double stroke (for example, entering 22 22 2022 instead of the intended 22 2 2022). We will only allow dates where the user input matches the corresponding GregorianCalendar values. If you wish, you can control this by using drop-downs or a Calendar pop up tool for the date field and only allowing valid days and months (in which case an OCCCDateException will never be thrown). If you do this, make sure you account for leap years and such. Given that Java is such a rich language it is a little surprising that it doesn't come with a Calendar pop up but nope you have to write that yourself if you want it.

We don't want the "default close operation" so make sure that if the application contains data that has changed from the most recent load, if the user clicks the closing X give them the usual pop up ("Save before exit?") so you won't accidentally throw away data.

answered
User Paloma
by
8.4k points