private Button buildPositiveButton(String text, boolean response) { Button button = buildButton(text, response); button.setDefaultButton(true); return button; }
public boolean showConfirmDialog(String title, String header, String content, AlertType alertType) { final Alert alert = new Alert(alertType); alert.setTitle(title); alert.setHeaderText(header); alert.setContentText(content); alert.getButtonTypes().clear(); alert.getButtonTypes().addAll(ButtonType.YES, ButtonType.NO); //Deactivate Defaultbehavior for yes-Button: Button yesButton = (Button) alert.getDialogPane().lookupButton( ButtonType.YES ); yesButton.setDefaultButton( false ); //Activate Defaultbehavior for no-Button: Button noButton = (Button) alert.getDialogPane().lookupButton( ButtonType.NO ); noButton.setDefaultButton( true ); final Optional<ButtonType> result = alert.showAndWait(); return result.get() == ButtonType.YES; }
Button okButton = (Button) alert.getDialogPane().lookupButton(ButtonType.OK); okButton.setDefaultButton(false);
Button buttonTwo = (Button) alert.getDialogPane().lookupButton(buttonTypeTwo); buttonTwo.setDefaultButton(true); Button buttonThree = (Button) alert.getDialogPane().lookupButton(buttonTypeThree); buttonThree.setCancelButton(true);
private Button addWriteButton() { Button btn = new Button("Write File"); btn.setDefaultButton(true); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { messageText.setFill(Color.FIREBRICK); messageText.setText("Write to file..."); if (isValidData()) { writeToFile(); } } }); return btn; }
/** * Create a button for the button bar * * @param type * the button id * @param label * the label * @param defaultOkButton * <code>true</code> if it is the default button {@link Button#defaultButtonProperty()} * @param defaultCancel * <code>true</code> if it is the cancel button {@link Button#cancelButtonProperty()} * @return the button */ protected Button createButtonForBar(final int type, String label, boolean defaultOkButton, boolean defaultCancel) { Button b = new Button(label); b.setDefaultButton(defaultOkButton); b.setCancelButton(defaultCancel); b.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { buttonPressed(type); } }); return b; }
/** * Shows a question dialog. * * @param message the message * @param defaultYes true if yes is the default button * @return true if yes, false if no */ public boolean showQuestionDialog(String message, boolean defaultYes) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(FxFxBundle.getString("QUESTION")); setAlertMessage(alert, message); alert.getButtonTypes().clear(); alert.getButtonTypes().addAll(ButtonType.YES, ButtonType.NO); Button noButton = (Button) alert.getDialogPane().lookupButton(ButtonType.NO); Button yesButton = (Button) alert.getDialogPane().lookupButton(ButtonType.YES); noButton.setDefaultButton(!defaultYes); yesButton.setDefaultButton(defaultYes); Optional<ButtonType> result = alert.showAndWait(); return result.isPresent() && result.get() == ButtonType.YES; }
private void buildActions() { okButton.getStyleClass().addAll("button-transparent-border-transparent"); okButton.setDefaultButton(true); okButton.setText(controller.getGLocalised("DONE_LABEL").toUpperCase()); cancelButton.getStyleClass().addAll("button-transparent-border-transparent"); cancelButton.setText(controller.getGLocalised("CANCEL_LABEL").toUpperCase()); actions.getStyleClass().add("form-actions-inline-editor-wrapper"); actions.getChildren().addAll(NodeHelper.horizontalSpacer(), cancelButton, okButton); allOverContainer.getChildren().add(actions); VBox.setMargin(actions, new Insets(16, 0, 0, 0)); cancelButton.setOnAction(e -> onCancel()); okButton.setOnAction(e -> onOk()); }
confirmButton.setDefaultButton(true);
/** * @{inheritedDoc} */ @Override public void buildFrom(IEmaginController controller, VLViewComponentXML configuration) { super.buildFrom(controller, configuration); button.setDefaultButton(configuration.booleanPropertyValueOf(XMLConstants.DEFAULT).orElse(false)); ComponentToLabeledHelper.setTooltip(configuration, button, (AbstractViewController) controller); IconUtils.setIcon(button, configuration); NodeHelper.styleClassAddAll(button, configuration); button.getStyleClass().add("ep-button"); // content display final String upperCase = configuration.getPropertyValue("upperCase"); ComponentToLabeledHelper.setText(configuration, button, "true".equalsIgnoreCase(upperCase), (AbstractViewController) controller); if(AbstractApplicationRunner.isDesktop()) { final String displayMode = configuration.getPropertyValue(XMLConstants.HYPERLINK_DISPLAY_MODE, "LEFT"); button.setContentDisplay(ContentDisplay.valueOf(displayMode)); } else { final String displayMode = configuration.getPropertyValue(XMLConstants.HYPERLINK_DISPLAY_MODE); if(StringUtils.isNotBlank(displayMode)) { button.setContentDisplay(ContentDisplay.valueOf(displayMode)); } } }
private void buildActions() { okButton.getStyleClass().addAll("flat-button", "transparent-focus"); okButton.setFocusTraversable(false); okButton.setDefaultButton(true); okButton.setText(controller.getGLocalised("DONE_LABEL").toUpperCase());
button.setText(controller.getLocalised(title).toUpperCase()); button.setDefaultButton(true);
/** * @{inheritedDoc} */ @Override public void buildFrom(IEmaginController controller, VLViewComponentXML configuration) { super.buildFrom(controller, configuration); final String title = configuration.getPropertyValue(XMLConstants.LABEL); NodeHelper.setLabel(button, configuration, (AbstractViewController) controller); if (!StringUtils.isEmpty(title)) { // ad fake indicator to the button to occupy the place // so when the task is runned, the label do not move final ProgressIndicator fakewaiting = new ProgressIndicator(); fakewaiting.managedProperty().bind(fakewaiting.visibleProperty()); fakewaiting.setVisible(false); // fakewaiting.getStyleClass().add(BUTTON_PROCESSING_PROGRESS); fakewaiting.maxHeight(8); fakewaiting.maxWidth(8); button.setGraphic(fakewaiting); } button.setDefaultButton(configuration.booleanPropertyValueOf(XMLConstants.DEFAULT).orElse(false)); ComponentToLabeledHelper.setTooltip(configuration, button, (AbstractViewController) controller); NodeHelper.styleClassAddAll(button, configuration, XMLConstants.STYLE_CLASS); }
off.setDefaultButton(true); hbox.getChildren().add(off);
okButton.setDefaultButton(true);
button.setDefaultButton(buttonData != null && buttonData.isDefaultButton()); button.setOnAction(ae -> setResult(buttonType));
Button b1 = new Button(); b1.setText("Default (push to enable Tab 'Progress')"); b1.setDefaultButton(true); b1.setTooltip(new Tooltip("This is a ToolTip")); b1.setOnAction(new EventHandler<ActionEvent>() { b2.setText("Default"); b2.setDisable(true); b2.setDefaultButton(true); buttonBox.getChildren().add(b2); Button b3 = new Button();