dialog.setGraphic(FontAwesome.LOCK.view()); final DialogPane pane = dialog.getDialogPane(); pane.getStyleClass().add("authentication"); final Scene scene = pane.getScene(); BrandUtil.applyBrand(injector, stage, scene); pane.getButtonTypes().addAll(ButtonType.CANCEL, authButtonType); grid.add(password, 1, 1); final Node loginButton = pane.lookupButton(authButtonType); ); pane.setContent(grid); Platform.runLater(username::requestFocus);
@Override public void showError(String title, String message, Throwable ex) { final Alert alert = new Alert(Alert.AlertType.ERROR); final Scene scene = alert.getDialogPane().getScene(); alert.setContentText(message); alert.setGraphic(FontAwesome.EXCLAMATION_TRIANGLE.view()); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); expContent.add(textArea, 0, 1); alert.getDialogPane().setExpandableContent(expContent);
@Override public void requestLayout() { if (performingLayout) { return; } super.requestLayout(); }
dialogPane.getStyleClass().add("jfx-alert-overlay"); dialogPane.setContent(materialNode); setDialogPane(dialogPane); dialogPane.getScene().setFill(Color.TRANSPARENT); dialogPane.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> { if (this.isOverlayClose()) { hide(); Animation animation = currentAnimation.createShowingAnimation(dialogPane.getContent(), dialogPane); if (animation != null) { animation.play(); eventHandlerManager.addEventHandler(DialogEvent.DIALOG_HIDDEN, event -> removeLayoutListeners()); getDialogPane().getScene().getWindow().addEventFilter(KeyEvent.KEY_PRESSED, keyEvent -> { if (keyEvent.getCode() == KeyCode.ESCAPE) { if (!isHideOnEscape()) {
public static <F> Optional<F> showAndWaitDialog(Window window, F parent, Function<String, F> folderCreator, Predicate<String> folderUnique) { Objects.requireNonNull(window); Objects.requireNonNull(parent); Objects.requireNonNull(folderCreator); Objects.requireNonNull(folderUnique); Dialog<F> dialog = new Dialog<>(); try { dialog.setTitle(RESOURCE_BUNDLE.getString("NewFolder")); dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); NewFolderPane<F> newProjectPane = new NewFolderPane<>(folderCreator, folderUnique); newProjectPane.setPrefSize(350, 100); dialog.getDialogPane().lookupButton(ButtonType.OK).disableProperty().bind(newProjectPane.validatedProperty().not()); dialog.getDialogPane().setContent(newProjectPane); dialog.setResizable(true); dialog.initOwner(window); dialog.setResultConverter(buttonType -> buttonType == ButtonType.OK ? newProjectPane.createFolder() : null); return dialog.showAndWait(); } finally { dialog.close(); } } }
public FontSelectorDialog(Font defaultFont) { fontPanel = new FontPanel(); fontPanel.setFont(defaultFont); setResultConverter(dialogButton -> dialogButton == ButtonType.OK ? fontPanel.getFont() : null); final DialogPane dialogPane = getDialogPane(); setTitle(localize(asKey("font.dlg.title"))); //$NON-NLS-1$ dialogPane.setHeaderText(localize(asKey("font.dlg.header"))); //$NON-NLS-1$ dialogPane.getStyleClass().add("font-selector-dialog"); //$NON-NLS-1$ dialogPane.getStylesheets().add(FontSelectorDialog.class.getResource("dialogs.css").toExternalForm()); //$NON-NLS-1$ dialogPane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); dialogPane.setContent(fontPanel); }
DialogPane dialogPane = new DialogPane(); dialogPane.getButtonTypes().setAll(ButtonType.OK); dialogPane.setHeaderText("Processing file"); dialogPane.setContent(progressBar); dialogPane.lookupButton(ButtonType.OK).setDisable(true); Dialog dialog = new Dialog(); dialog.setDialogPane(dialogPane); dialogPane.lookupButton(ButtonType.OK).setDisable(false); progressBar.progressProperty().unbind(); progressBar.setProgress(1); dialogPane.setHeaderText("Processing complete"); }); dialogPane.lookupButton(ButtonType.OK).setDisable(false); progressBar.progressProperty().unbind(); progressBar.setProgress(0); dialogPane.setHeaderText("An error occurred"); });
public class CattleGenderDialog extends ChoiceDialog { public CattleGenderDialog( final Window owner ) { initOwner( owner ); // This is the key line to override button order. setDialogPane( new ButtonOrderPane() ); // This line will return the button order pane. final DialogPane dialogPane = getDialogPane(); dialogPane.setContent( pane ); dialogPane.getButtonTypes().addAll( ... ); } }
browseButton.setPrefWidth(-1); pathsField.setPrefWidth(400); DialogPane dialogPane = new DialogPane(); dialogPane.setHeaderText("Add RRD file(s)"); dialogPane.getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); dialogPane.setGraphic(new Region()); dialogPane.getGraphic().getStyleClass().addAll("source-icon", "dialog-icon"); dialogPane.setContent(pathHBox); this.setDialogPane(dialogPane); Button okButton = (Button) dialogPane.lookupButton(ButtonType.OK); Platform.runLater(pathsField::requestFocus);
private void updateGrid() { grid.getChildren().clear(); // add the message to the top of the dialog updateContentText(); // then build all the buttons int row = 1; for (final ButtonType buttonType : getDialogPane().getButtonTypes()) { if (buttonType == null) continue; final Button button = (Button)getDialogPane().lookupButton(buttonType); GridPane.setHgrow(button, Priority.ALWAYS); GridPane.setVgrow(button, Priority.ALWAYS); grid.add(button, 0, row++); } // // last button gets some extra padding (hacky) // GridPane.setMargin(buttons.get(buttons.size() - 1), new Insets(0,0,10,0)); getDialogPane().setContent(grid); getDialogPane().requestLayout(); }
/** * 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); }
@Override protected double computePrefWidth(double height) { boolean isDefault = true; double pw = 0; for (ButtonType buttonType : getDialogPane().getButtonTypes()) { Button button = (Button) getDialogPane().lookupButton(buttonType); double buttonPrefWidth = button.getGraphic().prefWidth(-1); if (isDefault) { pw = buttonPrefWidth; isDefault = false; } else { pw = Math.min(pw, buttonPrefWidth); } } return pw + gapSize; }
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));
pane.getStyleClass().add("progress"); }); pane.setContent(box); pane.setMaxWidth(Double.MAX_VALUE); final Scene scene = pane.getScene(); BrandUtil.applyBrand(injector, stage, scene);
private void showLicensePopup() { Alert licenseAlert = new Alert(AlertType.INFORMATION); licenseAlert.setWidth(500); licenseAlert.setHeaderText("License"); ScrollPane scroll = new ScrollPane(); try { scroll.setContent(new TextArea(IOUtils.toString(getClass().getResourceAsStream("LICENSE"), StandardCharsets.UTF_8))); } catch (IOException e) { e.printStackTrace(); } licenseAlert.getDialogPane().setContent(scroll); licenseAlert.showAndWait(); }
this.getDialogPane().setContent(repositoryDetailsPanel); this.getDialogPane().getButtonTypes().setAll(ButtonType.FINISH, ButtonType.CANCEL); }); }); this.getDialogPane().getButtonTypes().setAll(ButtonType.CANCEL); this.getDialogPane().setContent(chooseRepositoryTypePanel); this.getDialogPane().setMinSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
dialogPane.setHeaderText(getString("progress.dlg.header")); //$NON-NLS-1$ dialogPane.getStyleClass().add("progress-dialog"); //$NON-NLS-1$ dialogPane.getStylesheets().add(ProgressDialog.class.getResource("dialogs.css").toExternalForm()); //$NON-NLS-1$ contentText.setWrapText(true); vbox.getChildren().add(0, contentText); contentText.textProperty().bind(dialogPane.contentTextProperty()); dialogPane.setContent(vbox);
private void addLinkToDialog(DialogPane dialogPane, CommandLinksButtonType link) { typeMap.put(link.getButtonType(), link); dialogPane.getButtonTypes().add(link.getButtonType()); }
@Override protected double computePrefHeight(double width) { double ph = getDialogPane().getHeader() == null ? 0 : 10; for (ButtonType buttonType : getDialogPane().getButtonTypes()) { Button button = (Button) getDialogPane().lookupButton(buttonType); ph += button.prefHeight(width) + gapSize; } // TODO remove magic number return ph * 1.2; } };
private static Alert setDefaultButton ( Alert alert, ButtonType defBtn ) { DialogPane pane = alert.getDialogPane(); for ( ButtonType t : alert.getButtonTypes() ) ( (Button) pane.lookupButton(t) ).setDefaultButton( t == defBtn ); return alert; }