/**
* Displays a confirmation dialog box.
*
* @param node a node attached to the stage to be used as the owner of the dialog.
* @param header the header message for the dialog.
* @param content the main message for the dialog.
* @param icon the icon for the dialog.
* @param buttons the {@link ButtonType} that should be displayed on the confirmation dialog.
* @return the {@link ButtonType} corresponding to user's choice.
*/
public static ButtonType confirmDialog(Node node, String header, String content, Node icon, ButtonType... buttons) {
Dialog<ButtonType> dlg = new Dialog<>();
dlg.initOwner(Dialogs.getStage(node));
setAlwaysOnTop(dlg);
dlg.setTitle("binjr");
dlg.getDialogPane().setHeaderText(header);
dlg.getDialogPane().setContentText(content);
if (icon == null) {
icon = new Region();
icon.getStyleClass().addAll("dialog-icon", "help-icon");
}
dlg.getDialogPane().setGraphic(icon);
if (buttons == null || buttons.length == 0) {
buttons = new ButtonType[]{ButtonType.YES, ButtonType.NO};
}
dlg.getDialogPane().getButtonTypes().addAll(buttons);
return dlg.showAndWait().orElse(ButtonType.CANCEL);
}
Dialogs.java 文件源码
java
阅读 37
收藏 0
点赞 0
评论 0
项目:binjr
作者:
评论列表
文章目录