I'm trying to set the default selected value for a ControlsFX CheckComboBox v8.0.3
with Java 8
I have tried the accepted answer in this question, but when I try
CheckComboBox.getCheckModel().check(0);
I get a class can not be referenced from a static context. When I try the following I get cannot resolve method check(int);
final CheckComboBox<String> checkComboBox = new CheckComboBox<>(strings);
checkComboBox.getCheckModel().check(0);
If I try getCheckmodel().selectIndices(0)
the first All1
is populated to the CheckComboBox
only when a new value is selected from the CheckComboBox
. Is there a way to refresh the comboxBox
after selecting the indices or any other way to achieve what I want?
Text numberTypeText = new Text("Features supported:");
final ObservableList<String> strings = FXCollections.observableArrayList();
strings.add("All1");
strings.add("All2");
strings.add("All3");
strings.add("All4");
strings.add("All5");
strings.add("All6");
strings.add("All7");
strings.add("All8");
final CheckComboBox<String> checkComboBox = new CheckComboBox<>(strings);
checkComboBox.getCheckModel().selectIndices(0);
checkComboBox.getCheckModel().getSelectedItems().addListener(new ListChangeListener<String>() {
public void onChanged(ListChangeListener.Change<? extends String> c) {
System.out.println(checkComboBox.getCheckModel().getSelectedItems());
}
});
Any help would be appreciated.