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

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

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

Alert.getDialogPane介绍

暂无

代码示例

代码示例来源:origin: pmd/pmd

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

代码示例来源:origin: speedment/speedment

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

代码示例来源:origin: speedment/speedment

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

代码示例来源: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

Alert alert = new Alert(AlertType.INFORMATION);
alert.getDialogPane().setContent( new Text("this is a pretty long message that "
        + "should not be truncated in this alert window, no matter "
        + "how long it is"));
alert.showAndWait();

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

Exception e = new Exception("An exception!!!!!!!!!!!!!!!!!");
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));

Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setHeaderText("An exception occurred!");
alert.getDialogPane().setExpandableContent(new ScrollPane(new TextArea(sw.toString())));
alert.showAndWait();

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

alert.getDialogPane().applyCss();
Node graphic = alert.getDialogPane().getGraphic();
alert.getDialogPane().getButtonTypes().addAll(buttonTypes);
alert.getDialogPane().setContentText(message);
alert.getDialogPane().setExpandableContent(new Group());
alert.getDialogPane().setExpanded(true);
alert.getDialogPane().setGraphic(graphic);
alert.setTitle(title);
alert.setHeaderText(headerText);

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

@FXML void handleHelpButton(ActionEvent event){
   Alert alert = new Alert(AlertType.INFORMATION);
   alert.setTitle("Help");
   alert.setHeaderText("Help");
   alert.setGraphic(new ImageView(this.getClass().getResource("img/help.png").toString()));
   alert.setContentText("Place the cursor over a button for hint.");
   Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
   stage.getIcons().add(new Image(this.getClass().getResource("img/help.png").toString()));        
   alert.showAndWait();
 }

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

ButtonType okBtn; //make sure this is of type ButtonBar.ButtonData.OK_DONE
ButtonType cancelBtn; //make sure this is of type ButtonBar.ButtonData.CANCEL_CLOSE
Alert alert = new Alert(AlertType.CONFIRMATION,"",okBtn,cancelBtn);
alert.getDialogPane().setContent(textFlow);

alert.setTitle("Some title");
alert.setHeaderText(null);
Optional<ButtonType> result = alert.showAndWait();

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

Alert dialog = new Alert(Alert.AlertType.ERROR);
dialog.setHeaderText("Connection Failed");
dialog.setContentText(this.getException().getMessage());

//FIXME: Remove after release 8u40
dialog.setResizable(true);
dialog.getDialogPane().setPrefSize(480, 320);

dialog.showAndWait();

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

JColorChooser colorChooser = new JColorChooser(java.awt.Color.CYAN);

SwingNode colorChooserNode = new SwingNode();
colorChooserNode.setContent(colorChooser);

Alert dialog = new Alert(Alert.AlertType.NONE);
// Guarantees dialog will be above (and will block input to) mainStage.
dialog.initOwner(mainStage);
dialog.setTitle("Select a color");

dialog.getDialogPane().setContent(colorChooserNode);

dialog.getDialogPane().getButtonTypes().setAll(
  ButtonType.OK, ButtonType.CANCEL);

Optional<ButtonType> response = dialog.showAndWait();
if (response.filter(r -> r == ButtonType.OK).isPresent()) {
  int rgb = colorChooser.getColor().getRGB();
  String hex = String.format("#%06x", rgb & 0xffffff);

  Text.setText(hex);
  ShortcutButton.setBackground(new Background(
    new BackgroundFill(Color.valueOf(hex), null, null)));
} else {
  System.out.println("User canceled");
}

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

Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Some title");

Text text = new Text("some right-to-left text here");

TextFlow textFlow = new TextFlow();
textFlow.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);

textFlow.getChildren().addAll(text);

alert.getDialogPane().setContent(textFlow);
alert.show();

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

if(condition)
   alert();


public void alert(){  //alert box

Alert alert = new Alert(AlertType.WARNING,"", ButtonType.YES, ButtonType.NO);  //new alert object
  alert.setTitle("Warning!");  //warning box title
  alert.setHeaderText("WARNING!!!");// Header
  alert.setContentText("File already exists. Overwrite?"); //Discription of warning
  alert.getDialogPane().setPrefSize(200, 100); //sets size of alert box 

  Optional<ButtonType> result = alert.showAndWait();
  if (result.get() == ButtonType.YES){
    // ... user chose YES
  } else {
    // ... user chose NO or closed the dialog
  }

}

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

alert.getDialogPane().setExpandableContent(textArea);

代码示例来源: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: org.tentackle/tentackle-fx

/**
 * Workaround for the bug that messages are not completely displayed if text is wrapped.
 *
 * @param alert the alert dialog
 * @param message the text message
 */
protected void setAlertMessage(Alert alert, String message) {
 alert.setHeaderText(null);
 Label textLabel = new Label();    // replace with non-wrapping label!
 textLabel.setWrapText(false);
 textLabel.setText(message);
 alert.getDialogPane().setContent(textLabel);
 alert.setResizable(true);   // RT-38998
}

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

alert.getDialogPane().setContentText("Some text");
DialogPane dialogPane = alert.getDialogPane();
GridPane grid = new GridPane();
ColumnConstraints graphicColumn = new ColumnConstraints();

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

public static String showConfirm(String title, String message, String... options) {
 final Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
 alert.initStyle(StageStyle.UTILITY);
 alert.setTitle("Choose an option");
 alert.setHeaderText(title);
 alert.setContentText(message);
 // To make enter key press the actual focused button, not the first one.
 // Just like pressing
 // "space".
 alert.getDialogPane().addEventFilter(KeyEvent.KEY_PRESSED, event -> {
  if (event.getCode().equals(KeyCode.ENTER)) {
   event.consume();
  }
 });
 if (options == null || options.length == 0) {
  options = new String[] {OK, CANCEL};
 }
 final List<ButtonType> buttons = new ArrayList<>();
 for (final String option : options) {
  buttons.add(new ButtonType(option));
 }
 alert.getButtonTypes().setAll(buttons);
 final Optional<ButtonType> result = alert.showAndWait();
 if (!result.isPresent()) {
  return CANCEL;
 } else {
  return result.get().getText();
 }
}

代码示例来源:origin: com.canoo.dolphin-platform/dolphin-platform-client-javafx

alert.getButtonTypes().addAll(reconnect);
alert.getDialogPane().setExpandableContent(expContent);
ButtonType result = alert.showAndWait().orElse(null);

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

public static void showException(String title, String message, Exception exception) {
 final Alert alert = new Alert(Alert.AlertType.ERROR);
 alert.initStyle(StageStyle.UTILITY);
 alert.setTitle("Exception");
 alert.setHeaderText(title);
 alert.setContentText(message);
 final StringWriter sw = new StringWriter();
 final PrintWriter pw = new PrintWriter(sw);
 exception.printStackTrace(pw);
 final String exceptionText = sw.toString();
 final Label label = new Label("Details:");
 final TextArea textArea = new TextArea(exceptionText);
 textArea.setEditable(false);
 textArea.setWrapText(true);
 textArea.setMaxWidth(Double.MAX_VALUE);
 textArea.setMaxHeight(Double.MAX_VALUE);
 GridPane.setVgrow(textArea, Priority.ALWAYS);
 GridPane.setHgrow(textArea, Priority.ALWAYS);
 final GridPane expContent = new GridPane();
 expContent.setMaxWidth(Double.MAX_VALUE);
 expContent.add(label, 0, 0);
 expContent.add(textArea, 0, 1);
 alert.getDialogPane().setExpandableContent(expContent);
 alert.showAndWait();
}

相关文章