So I'm trying to design an error message pop-up window for my GUI in Java/JavaFX. I have a separate FXML and Controller for the Error Message pop-up, and I'd like to call the pop-up whenever the user makes an error.
But I'd like to change the Label text of the message depending on what the error is. This is what I have:
if (carModel.isEmpty()) 
    showError("Please enter the model of your car.");
if (carColor.isEmpty())
    showError("Please enter the color of your car.");
public void showError (String text)  {
    Parent parentErrorMessage = FXMLLoader.load(getClass().getResource("ErrorMessage.fxml"));
    Scene sceneErrorMessage = new Scene(parentErrorMessage );   
    Stage errorStage = new Stage();     
    errorStage.setScene(sceneErrorMessage);
    errorStage.initModality(Modality.APPLICATION_MODAL);
    errorStage.setTitle("Error");
    errorStage.showAndWait();       
}
So I'd like to somehow pass in a string depending on where the error is taking place, and modify the Label that is in the ErrorMessage.fxml.
What is the best way to do this? I can't seem to figure it out. Thank you for any help!
