I am trying to pass a string to the next window so when it loads it will show the data retrieved from the database, based on that string.
I have run into an issue where it will only set the string AFTER the window has loaded and it has attempted to fill the data out from the database so I am always left with an empty table.
I hardcoded the string in to make sure my function that pulls and prints the data is correct and it is its working so that leaves me the issue where I am passing the string from the previous screen to the next.
This is my code
Stage app_stage =(Stage) ((Node) event.getSource()).getScene().getWindow();
FXMLLoader loader = new FXMLLoader(getClass().getResource("FXMLMenu.fxml"));
Parent menuPage_parent = loader.load();
FXMLMenuController menuCon = loader.<FXMLMenuController>getController();
usernametoPass = usernameField.getText();
menuCon.setUname(usernametoPass); //THIS is the function that sets the string
Scene menuPage_scene = new Scene(menuPage_parent);
app_stage.hide();
app_stage.setScene(menuPage_scene);
app_stage.show();
Now using this on load by printing the string I always get null because its not set. However if I print the string AFTER the load(via button press) it shows the correct string.
Is there a way to set it before it loads?