public class GuiUtils {
public static void runAlert(BiConsumer<Stage, AlertWindowController> setup) {
// JavaFX doesn't actually have a standard alert template. Instead the Scene Builder app will create FXML
// files for an alert window for you, and then you customise it as you see fit. I guess it makes sense in
// an odd sort of way.
Stage dialogStage = new Stage();
dialogStage.initModality(Modality.APPLICATION_MODAL);
FXMLLoader loader = new FXMLLoader(GuiUtils.class.getResource("alert.fxml"));
Pane pane = evalUnchecked(() -> (Pane) loader.load());
AlertWindowController controller = loader.getController();
setup.accept(dialogStage, controller);
dialogStage.setScene(new Scene(pane));
dialogStage.showAndWait();
}