Let's talk about JavaFX! But first, enjoy this gif of a dog failing at a dog show.
Now, on to our assignment.
Your mission is to create a desktop app for managing contacts. It should look like this:
- Create a project called "ContactsDesktop" using IntelliJ's JavaFX template.
- Edit
Main.javaso the title bar says "Contacts Desktop" and the window starts at 800x600. - Create a UI that looks like the screenshot below.
- Create a class called
Contactto store a name, phone, and email (all strings).- Override the
toStringmethod so it prints the contact like "Alice Smith, 814-867-5309, alice@theironyard.com".
- Override the
- Create a data structure for your
Contactobjects inController.java.ObservableList<Contact> contacts = FXCollections.observableArrayList();
- Create fields in
Controller.javafor all the controls (remember@FXML). - Make
Controller.javaimplementInitializable. - In your
initializemethod, call the list view'ssetItemsmethod to make it usecontacts. - When the "Add" button is clicked, create a new
Contactobject and add it tocontacts. - When the "Remove" button is clicked, remove the selected
Contactobject fromcontacts. - Don't add a new contact if any of the three fields are blank.
- Optional
- Save the contacts to a file (either JSON or custom format, your choice) whenever a contact is added or removed.
- Load that file in the
initializemethod inController.java, parse it, and populate thecontactswith it.

