javafx.scene.control.Button.setDefaultButton()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(285)

本文整理了Java中javafx.scene.control.Button.setDefaultButton()方法的一些代码示例,展示了Button.setDefaultButton()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.setDefaultButton()方法的具体详情如下:
包路径:javafx.scene.control.Button
类名称:Button
方法名:setDefaultButton

Button.setDefaultButton介绍

暂无

代码示例

代码示例来源:origin: torakiki/pdfsam

private Button buildPositiveButton(String text, boolean response) {
  Button button = buildButton(text, response);
  button.setDefaultButton(true);
  return button;
}

代码示例来源:origin: stackoverflow.com

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;
}

代码示例来源:origin: stackoverflow.com

Button okButton = (Button) alert.getDialogPane().lookupButton(ButtonType.OK);
okButton.setDefaultButton(false);

代码示例来源:origin: stackoverflow.com

Button buttonTwo = (Button) alert.getDialogPane().lookupButton(buttonTypeTwo);
buttonTwo.setDefaultButton(true);
Button buttonThree = (Button) alert.getDialogPane().lookupButton(buttonTypeThree);
buttonThree.setCancelButton(true);

代码示例来源:origin: com.thelastcheck.commons/tlc-commons-base

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;
}

代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.dialogs

/**
 * 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;
}

代码示例来源:origin: org.tentackle/tentackle-fx

/**
 * 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;
}

代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine

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());
}

代码示例来源:origin: stackoverflow.com

confirmButton.setDefaultButton(true);

代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine

/**
 * @{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));
  }
 }
}

代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine

private void buildActions() {
 okButton.getStyleClass().addAll("flat-button", "transparent-focus");
 okButton.setFocusTraversable(false);
 okButton.setDefaultButton(true);
 okButton.setText(controller.getGLocalised("DONE_LABEL").toUpperCase());

代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine

button.setText(controller.getLocalised(title).toUpperCase());
button.setDefaultButton(true);

代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine

/**
 * @{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);
}

代码示例来源:origin: com.aquafx-project/aquafx

off.setDefaultButton(true);
hbox.getChildren().add(off);

代码示例来源:origin: comtel2000/fx-experience

okButton.setDefaultButton(true);

代码示例来源:origin: org.controlsfx/controlsfx

button.setDefaultButton(buttonData != null && buttonData.isDefaultButton());
button.setOnAction(ae -> setResult(buttonType));

代码示例来源:origin: com.aquafx-project/aquafx

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();

相关文章