简体   繁体   English

Javafx TextInputDialog禁用ok按钮

[英]Javafx TextInputDialog Disable ok button

I am using the JDK8u45 and I am trying to use the text input dialog but is there a way to disable the ok button until I enable it? 我正在使用JDK8u45,我正在尝试使用文本输入对话框,但有没有办法禁用确定按钮,直到我启用它? I checked the java docs and did not see a disable feature. 我检查了java文档并没有看到禁用功能。 Is there another way to do this in java 8 if this does not work? 如果这不起作用,还有另一种方法在java 8中执行此操作吗?

Lookup the button and invoke setDisable on it. 查找按钮并在其上调用setDisable

TextInputDialog dialog = new TextInputDialog();
dialog.getDialogPane().lookupButton(ButtonType.OK).setDisable(true);

disable is a property, so you could bind the value to some condition if you wish (rather than explicitly calling setters to disable and re-enable it). disable是一个属性,因此如果您愿意,可以将值绑定到某个条件(而不是显式调用setter来禁用和重新启用它)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM