如何在 JavaFX 2.0 中创建和显示常用对话框(错误、警告、确认)? [英] How to create and show common dialog (Error, Warning, Confirmation) in JavaFX 2.0?

查看:32
本文介绍了如何在 JavaFX 2.0 中创建和显示常用对话框(错误、警告、确认)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 JavaFX 2.0 中创建和显示常见对话框(错误、警告、确认)?我找不到任何标准"类,例如 DialogDialogBoxMessage 之类的.

How do I create and show common dialogs (Error, Warning, Confirmation) in JavaFX 2.0? I can't find any "standard" classes like Dialog, DialogBox, Message or something.

推荐答案

最近发布的JDK 1.8.0_40 新增支持 JavaFX 对话框、警报等.例如,要显示确认对话框,可以使用 Alert 类:

Recently released JDK 1.8.0_40 added support for JavaFX dialogs, alerts, etc. For example, to show a confirmation dialog, one would use the Alert class:

Alert alert = new Alert(AlertType.CONFIRMATION, "Delete " + selection + " ?", ButtonType.YES, ButtonType.NO, ButtonType.CANCEL);
alert.showAndWait();

if (alert.getResult() == ButtonType.YES) {
    //do stuff
}

这是此版本中添加的类的列表:

Here's a list of added classes in this release:

这篇关于如何在 JavaFX 2.0 中创建和显示常用对话框(错误、警告、确认)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆