【问题标题】:How to show automatically the details in alert?如何在警报中自动显示详细信息?
【发布时间】:2016-06-27 08:18:19
【问题描述】:

我创建了一个类型为 INFORMATION 的警报。然后我创建了一个 TextArea 并使用 GridPane 添加到警报中。现在我的问题是如何自动显示警报的详细信息?

    Alert alert = new Alert(AlertType.INFORMATION);
    alert.setTitle("TODO Liste");
    alert.setContentText("Alle TODO's in der Liste:");
    alert.initStyle(StageStyle.UTILITY);

    TextArea textArea = new TextArea();

    GridPane content = new GridPane();
    content.setMaxWidth(Double.MAX_VALUE);
    content.add(textArea, 0, 0);

    alert.getDialogPane().setExpandableContent(content);
    alert.showAndWait();

编辑:

截图

【问题讨论】:

  • 要查看 TextArea 我需要点击“显示详细信息”,否则它不会显示
  • 您应该锁定相当不错的 JavaFX 教程 @ Code Maker - 尤其是 [JavaFX 对话框] (code.makery.ch/blog/javafx-dialogs-official)。

标签: javafx textarea alert


【解决方案1】:

您设置的是可扩展内容,而不是内容!因此,将您设置Alert 内容的行更改为:

alert.getDialogPane().setContent(content);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-26
    • 1970-01-01
    • 1970-01-01
    • 2016-07-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多