Reputation: 2414
What is the simple way to check whether any item is selected in JavaFX ComboBox or if it is left without selected item?
Checking for ComboBox in this state should return FALSE:
Checking for ComboBox in this state should return TRUE:
Upvotes: 7
Views: 28397
Reputation: 1
!(cmbDia.getValue()==null) && !(cmbMes.getValue()==null) && !(cmbAno.getValue()==null)//fue todo gracias :)
Upvotes: 0
Reputation: 2414
So I found a simple way:
boolean isMyComboBoxEmpty = (myComboBox.getValue() == null);
Upvotes: 9
Reputation: 82461
You can use
boolean isMyComboBoxEmpty = myComboBox.getSelectionModel().isEmpty();
Which also works, if you have a null
item among the ComboBox
items.
Upvotes: 22