Top Description Inners Fields Constructors Methods
org.controlsfx.control

public Class CheckListView<T>

extends ListView<T>
Class Inheritance
Type Parameters
<T>
The type of the data in the CheckListView.
Imports
java.util.HashMap, .Map, javafx.beans.property.BooleanProperty, .ObjectProperty, .SimpleObjectProperty, javafx.collections.FXCollections, .ListChangeListener, .ObservableList, javafx.scene.Parent, javafx.scene.control.CheckBox, .ListView, javafx.scene.control.cell.CheckBoxListCell, javafx.scene.input.KeyCode, .KeyEvent

A simple UI control that makes it possible to select zero or more items within a ListView without the need to set a custom cell factory or manually create boolean properties for each row - simply use the check model to request the current selection state.

Screenshot

The following screenshot shows the CheckListView with some sample data:
Screenshot of CheckListView

Code Example:

To create the CheckListView shown in the screenshot, simply do the following:

// create the data to show in the CheckListView 
final ObservableList<String> strings = FXCollections.observableArrayList();
for (int i = 0; i <= 100; i++) {
    strings.add("Item " + i);
}

// Create the CheckListView with the data 
final CheckListView<String> checkListView = new CheckListView<>(strings);

// and listen to the relevant events (e.g. when the selected indices or 
// selected items change).
checkListView.getCheckModel().getCheckedItems().addListener(new ListChangeListener<String>() {
    public void onChanged(ListChangeListener.Change<? extends String> c) {
        System.out.println(checkListView.getCheckModel().getCheckedItems());
    }
});

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private ObjectProperty<IndexedCheckModel<T>>
checkModel

Properties

private final Map<T, BooleanProperty>
itemBooleanMap

Private fields

Constructor Summary

AccessConstructor and Description
public
CheckListView()

Creates a new CheckListView instance with an empty list of choices.

public
CheckListView(ObservableList<T>
The items to display within the CheckListView.
items
)

Creates a new CheckListView instance with the given items available as choices.

Method Summary

Modifier and TypeMethod and Description
public final ObjectProperty<IndexedCheckModel<T>>
checkModelProperty()

The check model provides the API through which it is possible to check single or multiple items within a CheckListView, as well as inspect which items have been checked by the user.

public final IndexedCheckModel<T>
getCheckModel()

Returns the currently installed check model.

public BooleanProperty
getItemBooleanProperty(int index)

Returns the BooleanProperty for a given item index in the CheckListView.

public BooleanProperty
getItemBooleanProperty(T item)

Returns the BooleanProperty for a given item in the CheckListView.

public final void
setCheckModel(IndexedCheckModel<T> value)

Sets the 'check model' to be used in the CheckListView - this is the code that is responsible for representing the selected state of each CheckBox - that is, whether each CheckBox is checked or not (and not to be confused with the selection model concept, which is used in the ListView control to represent the selection state of each row)..

Inherited from javafx.scene.control.ListView:
cellFactoryPropertycreateDefaultSkinediteditablePropertyeditAnyEventeditCancelEventeditCommitEventeditingIndexPropertyeditStartEventfixedCellSizePropertyfocusModelPropertygetCellFactorygetClassCssMetaDatagetControlCssMetaDatagetEditingIndexgetFixedCellSizegetFocusModelgetItemsgetOnEditCancelgetOnEditCommitgetOnEditStartgetOnScrollTogetOrientationgetPlaceholdergetSelectionModelisEditableitemsPropertyonEditCancelPropertyonEditCommitPropertyonEditStartPropertyonScrollToPropertyorientationPropertyplaceholderPropertyqueryAccessibleAttributerefreshscrollToscrollToselectionModelPropertysetCellFactorysetEditablesetFixedCellSizesetFocusModelsetItemssetOnEditCancelsetOnEditCommitsetOnEditStartsetOnScrollTosetOrientationsetPlaceholdersetSelectionModel

Field Detail

checkModelback to summary
private ObjectProperty<IndexedCheckModel<T>> checkModel

Properties

itemBooleanMapback to summary
private final Map<T, BooleanProperty> itemBooleanMap

Private fields

Constructor Detail

CheckListViewback to summary
public CheckListView()

Creates a new CheckListView instance with an empty list of choices.

CheckListViewback to summary
public CheckListView(ObservableList<T> items)

Creates a new CheckListView instance with the given items available as choices.

Parameters
items:ObservableList<T>

The items to display within the CheckListView.

Method Detail

checkModelPropertyback to summary
public final ObjectProperty<IndexedCheckModel<T>> checkModelProperty()

The check model provides the API through which it is possible to check single or multiple items within a CheckListView, as well as inspect which items have been checked by the user. Note that it has a generic type that must match the type of the CheckListView itself.

getCheckModelback to summary
public final IndexedCheckModel<T> getCheckModel()

Returns the currently installed check model.

getItemBooleanPropertyback to summary
public BooleanProperty getItemBooleanProperty(int index)

Returns the BooleanProperty for a given item index in the CheckListView. This is useful if you want to bind to the property.

getItemBooleanPropertyback to summary
public BooleanProperty getItemBooleanProperty(T item)

Returns the BooleanProperty for a given item in the CheckListView. This is useful if you want to bind to the property.

setCheckModelback to summary
public final void setCheckModel(IndexedCheckModel<T> value)

Sets the 'check model' to be used in the CheckListView - this is the code that is responsible for representing the selected state of each CheckBox - that is, whether each CheckBox is checked or not (and not to be confused with the selection model concept, which is used in the ListView control to represent the selection state of each row)..

org.controlsfx.control back to summary

private Class CheckListView.CheckListViewBitSetCheckModel<T>

extends CheckBitSetModelBase<T>
Class Inheritance

Support classes

Field Summary

Modifier and TypeField and Description
private final ObservableList<T>
items

* Internal properties * *

Constructor Summary

AccessConstructor and Description
pack-priv
CheckListViewBitSetCheckModel(final ObservableList<T> items, final Map<T, BooleanProperty> itemBooleanMap)

* Constructors * *

Method Summary

Modifier and TypeMethod and Description
public T
getItem(int index)

Implements abstract org.controlsfx.control.CheckBitSetModelBase.getItem.

Implements org.controlsfx.control.IndexedCheckModel.getItem.

* Implementing abstract API * *

public int
getItemCount()

Implements abstract org.controlsfx.control.CheckBitSetModelBase.getItemCount.

Implements org.controlsfx.control.CheckModel.getItemCount.

Returns the count of items in the control.

public int
Inherited from org.controlsfx.control.CheckBitSetModelBase:
checkcheckcheckAllcheckIndicesclearCheckclearCheckclearChecksgetCheckedIndicesgetCheckedItemsgetItemBooleanPropertyisCheckedisCheckedisEmptytoggleCheckStatetoggleCheckStateupdateMap

Field Detail

itemsback to summary
private final ObservableList<T> items

* Internal properties * *

Constructor Detail

CheckListViewBitSetCheckModelback to summary
pack-priv CheckListViewBitSetCheckModel(final ObservableList<T> items, final Map<T, BooleanProperty> itemBooleanMap)

* Constructors * *

Method Detail

getItemback to summary
public T getItem(int index)

Implements abstract org.controlsfx.control.CheckBitSetModelBase.getItem.

Implements org.controlsfx.control.IndexedCheckModel.getItem.

* Implementing abstract API * *

Annotations
@Override
getItemCountback to summary
public int getItemCount()

Implements abstract org.controlsfx.control.CheckBitSetModelBase.getItemCount.

Implements org.controlsfx.control.CheckModel.getItemCount.

Doc from org.controlsfx.control.CheckModel.getItemCount.

Returns the count of items in the control.

Annotations
@Override
getItemIndexback to summary
public int getItemIndex(T item)

Implements abstract org.controlsfx.control.CheckBitSetModelBase.getItemIndex.

Implements org.controlsfx.control.IndexedCheckModel.getItemIndex.

Doc from org.controlsfx.control.IndexedCheckModel.getItemIndex.

Returns the index of the given item.

Annotations
@Override