Class CheckListView<T>

  • Type Parameters:
    T - The type of the data in the CheckListView.
    All Implemented Interfaces:
    Styleable, EventTarget, Skinnable

    public class CheckListView<T>
    extends ListView<T>
    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());
         }
     });
     
    • Property Detail

      • checkModel

        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.
    • Constructor Detail

      • CheckListView

        public CheckListView()
        Creates a new CheckListView instance with an empty list of choices.
      • CheckListView

        public CheckListView​(ObservableList<T> items)
        Creates a new CheckListView instance with the given items available as choices.
        Parameters:
        items - The items to display within the CheckListView.
    • Method Detail

      • getItemBooleanProperty

        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.
      • getItemBooleanProperty

        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.
      • setCheckModel

        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)..
      • getCheckModel

        public final IndexedCheckModel<T> getCheckModel()
        Returns the currently installed check model.
      • checkModelProperty

        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.