How to set default value in javafx comboBox?

I need to set the default value for a ComboBox from an ObservableArrayList , I am trying to set the first value in my ArrayList as the default value.

 List = FXCollections.observableArrayList(arrayList); comboBox.setItems(List); 
+5
source share
2 answers
 comboBox.getSelectionModel().selectFirst(); 
+19
source
 comboBox.getSelectionModel().select(index); 

where index is the integer position of the item to select in the selection model, or a value of the same type as the List array.

+4
source

Source: https://habr.com/ru/post/1241249/


All Articles