java 如何检查是否在 JavaFX ComboBox 中选择了任何项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36963551/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 02:03:28 来源:igfitidea点击:
How to check if any item is selected in JavaFX ComboBox
提问by PeterB
回答by fabian
You can use
您可以使用
boolean isMyComboBoxEmpty = myComboBox.getSelectionModel().isEmpty();
Which also works, if you have a null
item among the ComboBox
items.
如果您在null
项目中有一个项目,这也有效ComboBox
。
回答by PeterB
So I found a simple way:
于是我找到了一个简单的方法:
boolean isMyComboBoxEmpty = (myComboBox.getValue() == null);
回答by Andres Bonfil
!(cmbDia.getValue()==null) && !(cmbMes.getValue()==null) && !(cmbAno.getValue()==null)//fue todo gracias :)