【发布时间】: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)。