When a user clicks the settings button, I open the dialog as follows...
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(ResourceUtility.getInstance().getResource("views/TimeZoneDialog.fxml"));
fxmlLoader.load();
// Set background outside the new dialog to transparent black (modal UX)
stage.getScene().getRoot().setOpacity(0.2);
stage.getScene().setFill(Paint.valueOf("BLACK"));
// Create new stage to contain the dialog
Stage timeZoneDialogStage = new Stage();
timeZoneDialogStage.initModality(Modality.APPLICATION_MODAL);
timeZoneDialogStage.initStyle(StageStyle.UNDECORATED);
timeZoneDialogStage.initOwner(stage);
timeZoneDialogStage.centerOnScreen();
timeZoneDialogStage.setScene(new Scene(fxmlLoader.getRoot()));
timeZoneDialogStage.showAndWait();
// Set background back to what it was before
stage.getScene().getRoot().setOpacity(1);
stage.getScene().setFill(null);
}
...this is in a controller class (implements Initializable) and when we created the stage for its scene, we got the controller and called setStage on it so we can do things like have a button that causes it to go to / from full screen, etc. Are you suggesting to have only one instance of the stage for the modal dialog and use something like toFront and toBack instead?