pane.getButtonTypes().addAll(ButtonType.CANCEL, authButtonType);
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( ... ); } }
private void addLinkToDialog(DialogPane dialogPane, CommandLinksButtonType link) { typeMap.put(link.getButtonType(), link); dialogPane.getButtonTypes().add(link.getButtonType()); }
static boolean containsCancelButton(Dialog<?> dialog) { DialogPane dialogPane = dialog.getDialogPane(); for (ButtonType type : dialogPane.getButtonTypes()) { if (type.getButtonData() == ButtonData.CANCEL_CLOSE) { return true; } } return false; } }
static void forcefullyHideDialog(javafx.scene.control.Dialog<?> dialog) { // for the dialog to be able to hide, we need a cancel button, // so lets put one in now and then immediately call hide, and then // remove the button again (if necessary). DialogPane dialogPane = dialog.getDialogPane(); if (containsCancelButton(dialog)) { dialog.hide(); return; } dialogPane.getButtonTypes().add(ButtonType.CANCEL); dialog.hide(); dialogPane.getButtonTypes().remove(ButtonType.CANCEL); }
private void validateActionState() { final List<ButtonType> currentPaneButtons = dialog.getDialogPane().getButtonTypes(); if (getFlow().canAdvance(currentPage.orElse(null))) { currentPaneButtons.remove(ButtonType.FINISH); } else { currentPaneButtons.remove(BUTTON_NEXT); } validateButton( BUTTON_PREVIOUS, () -> pageHistory.isEmpty()); validateButton( BUTTON_NEXT, () -> invalidProperty.get()); validateButton( ButtonType.FINISH, () -> invalidProperty.get()); }
@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; }
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.getButtonTypes().addListener((ListChangeListener<? super ButtonType>)c -> updateGrid());
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));
@Override protected void addCustomButtons(final DialogPane dialogPane) { // add 'Calculate' button to button bar final ButtonType bTypeCalculate = new ButtonType(context.getResources().getString( "st.dlg.statistic.calculate.Action.text"), ButtonBar.ButtonData.OK_DONE); dialogPane.getButtonTypes().add(bTypeCalculate); final Button buttonCalculate = (Button) dialogPane.lookupButton(bTypeCalculate); // set action event filter for this custom button // => the event must be consumed, otherwise the dialog will be closed buttonCalculate.addEventFilter(ActionEvent.ACTION, (event) -> { event.consume(); onCalculate(event); }); }
@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; } };
/** * Displays the information dialog for the specified FXML file. The dialog contains only a Close button. * * @param fxmlFilename FXML filename of the dialog content * @param parent parent window of the dialog * @param title dialog title comment */ protected void showInfoDialog(final String fxmlFilename, final Window parent, final String title) { final Parent root = loadDialogContent(fxmlFilename); setupDialogControls(); // create and show dialog final Dialog<ButtonType> dlg = createDialog(parent, title, root); dlg.getDialogPane().getButtonTypes().add(ButtonType.CLOSE); addCustomButtons(dlg.getDialogPane()); dlg.showAndWait(); triggerGC(); }
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 void popDialog(String title, String header, String content) { if (guiEnabled) Platform.runLater(() -> { Dialog<String> dialog = new Dialog<>(); dialog.setTitle(title); dialog.setHeaderText(header); TextArea textField = new TextArea(); dialog.setHeight(400); dialog.setResizable(true); dialog.getDialogPane().setContent(textField); dialog.getDialogPane().getButtonTypes().add(ButtonType.OK); textField.setEditable(false); textField.setText(content); textField.setWrapText(true); dialog.showAndWait(); }); if(print) System.out.println(title+":\t"+header+":\t"+content); }
/** * setup the control according to the given valueMap * * @param valueMap */ public void setup(Map<String, Object> valueMap) { // Create the custom dialog. dialog = new Dialog<Map<String, Object>>(); dialog.initOwner(stage); dialog.setTitle(I18n.get(form.getI18nId())); dialog.setHeaderText(form.getHeaderText()); // Set the icon (must be included in the project). URL iconUrl = this.getClass() .getResource("/icons/" + form.getIcon() + ".png"); if (iconUrl != null) dialog.setGraphic(new ImageView(iconUrl.toString())); // Set the button types. okButtonType = new ButtonType("Ok", ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(okButtonType, ButtonType.CANCEL); genericPanel = new GenericPanel(getStage(),form); dialog.getDialogPane().setContent(genericPanel); if (valueMap != null) { genericPanel.setValues(valueMap); } }
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(); }
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);
public static Optional<String> showAndWaitDialog(AbstractNodeBase node, Predicate<String> nodeNameUnique) { Dialog<String> dialog = new Dialog<>(); try { dialog.setTitle(RESOURCE_BUNDLE.getString("RenameFile")); dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); RenamePane renamePane = new RenamePane(node, nodeNameUnique); renamePane.setPrefSize(350, 100); dialog.getDialogPane().lookupButton(ButtonType.OK).disableProperty().bind(renamePane.validatedProperty().not()); dialog.getDialogPane().setContent(renamePane); dialog.setResizable(true); dialog.setResultConverter(buttonType -> buttonType == ButtonType.OK ? renamePane.getNameTextField().getText() : null); return dialog.showAndWait(); } finally { dialog.close(); } } }
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);