There appears to be a delay in applying my dark UI CSS to a stage when it first appears. This causes an ugly looking white flash. How can I prevent this? Code and demo gif below.
if (presetDialog == null) {
// Create the preset dialog
presetDialog = new Stage();
presetDialog.initOwner(stage);
presetDialog.setTitle("Edit Preset");
// Load fxml
FXMLLoader loader = new FXMLLoader(getClass().getResource("EditPreset.fxml"));
try {
loader.setController(this);
BorderPane pane = loader.load();
Scene scene = new Scene(pane);
scene.getStylesheets().addAll(stage.getScene().getStylesheets());
presetDialog.setScene(scene);
} catch (IOException e) {
e.printStackTrace();
}
}
presetDialog.showAndWait();