Question: Step 0 : Project Setup & Download Overview Set up a JavaFX project in IntelliJ. I have supplied all 7 files you will need. Download

Step 0: Project Setup & Download Overview
Set up a JavaFX project in IntelliJ. I have supplied all 7 files you will need. Download them and
move them into the appropriate places in your project (Java files together and fxml files
together). Here is a rundown of what you are being given:
1) CalculatorApp.java: fully completed already. Run this to launch the login screen.
You shouldnt need to edit this except to test the other scenes more easily.
2) Login.fxml: This will be the login screen. I supplied a simplistic scene to edit as
needed.
3) LoginController.java: This is given with variable definitions included. Additionally,
theres empty method definitions to fill in later, and some are already implemented.
4) Settings.fxml: This will be the settings screen and is empty like Login.fxml.
5) SettingsController.java: Like LoginController, this has variables already declared as
well as empty method definitions and 1 already implemented.
6) Calculator.fxml: This is the calculator screen. The layout is made with all IDs and
event references set up.
7) CalculatorController.java: Like the other controllers, this has the variables declared
and empty method definitions, as well as numButton() and logout() implemented.
If you run the project as-is, you should get a blank login screen. If you edit CalculatorApp.java to
load Calculator.fxml instead, you can see the Calculator scene, even without full functionality. If
this gives an error (likely a load error of some sort) open Calculator.fxml in SceneBuilder and
update the controller to be set to the CalculatorController in your project.
Step 1: Login Scene and LoginController.java
Login.fxml
First, open Login.fxml in SceneBuilder and design the scene. You dont
necessarily need to exactly match what I did, but the closer you are the easier
I will be able to help with debugging. Most of it should be straightforward but
note that the password field should be a PasswordField instead of a TextField.
The only difference is that typed letters automatically appear as *****.
Once the scene is laid out, make sure to set the controller to LoginController.
Then, ensure you set IDs for each of the elements listed in LoginController.
This is nameField, passwordField, and errorLabel. Also, ensure the buttons have methods listed
as events (openSettings() for Settings, login for Calculator Login). Once youre satisfied with
that, clear the text of the errorLabel so that it starts empty.
LoginController.java
login(): The goal is to validate the username and password and open the calculator scene if so.
Do this by manually checking if both the contents of nameField and passwordField match the
contents of username and password respectively. If both do, call openCalculator(); Else, set
errorLabel to be Invalid login credentials.
Additionally, in login(), put these 3 lines immediately after calling openCalculator(). It closes the
login screen when loading the calculator screen.
Button caller =(Button)event.getSource();
Stage stage =(Stage)caller.getScene().getWindow();
stage.close();
Testing: with this filled in, you can now do more testing. If you run the program to the login
screen and enter admin and password respectively (hardcoded values), you should be able
to load the calculator. If you didnt in step 0, you may need to open Calculator.fxml in
SceneBuilder and make sure the controller is set correctly to have this
work. Clicking settings will load an empty scene, which leads you into...
Step 2: Settings Scene and SettingsController.java
Settings.fxml
First, open Settings.fxml in SceneBuilder and design the scene. Its worth
note that this screen only simulates the profile saving there is no actual
saving of birthday or preferred language. The only saved part is the new
username and password if they are set. The new elements here are:
DatePicker: This element works with virtually 0 effort. Just drag it into the scene next to a label
and it works automatically.
RadioButton: These also work mostly automatically. However, you must set the Toggle Group
property of both buttons. It doesnt matter what, as long as they are the same. I suggest
language. This makes it so you can only select 1 at a time, not both. Test this to make sure it
works before moving on.
Like before, set the controller to SettingsController and set the IDs and events for each element.
You need IDs for datePicker, usernameField, passwordField, radioJava, radioPython,
errorLabel, and confirmLabel. Update should have event set to updateInfo, Save Profile
should be set to save, and Return to Login should be set to returnToLogin. Lastly, empty the
text of errorLabel and confirmLabel.
SettingsController.java
updateInfo(): Lets start here since it only requires 4 lines. The first 2 should update the value of
LoginController.username and LoginController.password to be the current text of
usernameField and passwordField

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!