In this blog you will learn how to use ControlsFX api based CheckComboBox. It is very useful control, here we have items with checkbox in ComboBox. I have explained the use of CheckComboBox and implementation step by step.Prerequisite: 1) Need to download controlsfx.jar from below link :
System.out.println(checkComboBox.getCheckModel().getSelectedItems());
http://fxexperience.com/downloads/controlsfx-8-40-142) Download link for Gluon Scene builder:
https://gluonhq.com/products/scene-builder/
https://gluonhq.com/products/scene-builder/
Please check the code given below. It’s easy to implement.
// create the data to
show in the CheckComboBox
show in the CheckComboBox
final
ObservableList<String> strings = FXCollections.observableArrayList();
ObservableList<String> strings = FXCollections.observableArrayList();
for (int i = 0; i
<= 100; i++) {
<= 100; i++) {
strings.add(“Item
” + i);
” + i);
}
// add listener to
listen the relevant events (e.g. when the selected indices or
listen the relevant events (e.g. when the selected indices or
selected items
change).
change).
checkComboBox.getCheckModel().getCheckedItems().addListener(new
ListChangeListener<String>()
ListChangeListener<String>()
{
public void onChanged(ListChangeListener.Change<?
extends String> c) {
extends String> c) {
System.out.println(checkComboBox.getCheckModel().getSelectedItems());
}
});
}
For detailed understanding please watch my video tutorial with a complete explanation step by step.