@Override public Optional<ButtonType> showWarning(String title, String message) { final Alert alert = new Alert(Alert.AlertType.CONFIRMATION); final Scene scene = alert.getDialogPane().getScene(); BrandUtil.applyBrand(injector, stage, scene); alert.setTitle("Confirmation"); alert.setHeaderText(title); alert.setContentText(message); alert.setGraphic(FontAwesome.EXCLAMATION_TRIANGLE.view()); return alert.showAndWait(); }
@Override public void showError(String title, String message, Throwable ex) { final Alert alert = new Alert(Alert.AlertType.ERROR); final Scene scene = alert.getDialogPane().getScene();
pane.getStyleClass().add("authentication"); final Scene scene = pane.getScene(); BrandUtil.applyBrand(injector, stage, scene);
dialogPane.setContent(materialNode); setDialogPane(dialogPane); dialogPane.getScene().setFill(Color.TRANSPARENT); eventHandlerManager.addEventHandler(DialogEvent.DIALOG_HIDDEN, event -> removeLayoutListeners()); getDialogPane().getScene().getWindow().addEventFilter(KeyEvent.KEY_PRESSED, keyEvent -> { if (keyEvent.getCode() == KeyCode.ESCAPE) { if (!isHideOnEscape()) {
pane.setMaxWidth(Double.MAX_VALUE); final Scene scene = pane.getScene(); BrandUtil.applyBrand(injector, stage, scene);
/** * @return The owner stage of the dialog */ public Stage getStage() { return (Stage)getDialogPane().getScene().getWindow(); }
Alert alert = new Alert(Alert.AlertType.WARNING, "I Warn You!", ButtonType.OK, ButtonType.CANCEL); DialogPane root = alert.getDialogPane(); Stage dialogStage = new Stage(StageStyle.UTILITY); for (ButtonType buttonType : root.getButtonTypes()) { ButtonBase button = (ButtonBase) root.lookupButton(buttonType); button.setOnAction(evt -> { root.setUserData(buttonType); dialogStage.close(); }); } // replace old scene root with placeholder to allow using root in other Scene root.getScene().setRoot(new Group()); root.setPadding(new Insets(10, 0, 10, 0)); Scene scene = new Scene(root); dialogStage.setScene(scene); dialogStage.initModality(Modality.APPLICATION_MODAL); dialogStage.setAlwaysOnTop(true); dialogStage.setResizable(false); dialogStage.showAndWait(); Optional<ButtonType> result = Optional.ofNullable((ButtonType) root.getUserData()); System.out.println("result: "+result.orElse(null));
/** * set the Content (since setContent of DialogPane is final this function has a different name) * this is a work around to have room for a help button so a grid is interwoven between the dialogpane * and the content we'd like to show * @param parent */ public void setContentNode(Node parent) { if (contentNode!=null) gridPane.getChildren().remove(contentNode); gridPane.add(parent, 0, 0); contentNode=parent; // resize the dialog // https://stackoverflow.com/a/31208445/1497139 this.wizard.getPrivateDialog().getDialogPane().getScene().getWindow().sizeToScene(); }
/** * Initializes the components used in the {@link ErrorDialog} */ private void initialise() { contentTextProperty().bind(Bindings.createStringBinding( () -> Optional.ofNullable(getException()).map(Exception::getMessage).orElse(null), exception)); getDialogPane().setExpandableContent(createExpandableContent()); // ensure that the dialog resizes correctly when the expanded state changes getDialogPane().expandedProperty().addListener(observable -> Platform.runLater(() -> { getDialogPane().requestLayout(); final Window window = getDialogPane().getScene().getWindow(); window.sizeToScene(); })); getDialogPane().setMinHeight(Region.USE_PREF_SIZE); }
Window w = alert.getDialogPane().getScene().getWindow(); w.sizeToScene(); }));
dialogPane.setContent(materialNode); setDialogPane(dialogPane); dialogPane.getScene().setFill(Color.TRANSPARENT); eventHandlerManager.addEventHandler(DialogEvent.DIALOG_HIDDEN, event -> removeLayoutListeners()); getDialogPane().getScene().getWindow().addEventFilter(KeyEvent.KEY_PRESSED, keyEvent -> { if (keyEvent.getCode() == KeyCode.ESCAPE) { if (!isHideOnEscape()) {
fxPropsManager.attachTo(dialog.getDialogPane().getScene().getWindow());