I have been trying to use the cell factories that are provided by the JavaFX CheckBoxTreeTableCell
, but I can't figure out how to make it work.
The Javadoc does not seem to match the implementation. For example:
public static <S,T> Callback<TreeTableColumn<S,T>,TreeTableCell<S,T>> forTreeTableColumn(Callback<Integer,ObservableValue<Boolean>> getSelectedProperty)
...
Parameters:
getSelectedProperty - A Callback that, given an object of type TreeTableColumn<S,T>, will return an ObservableValue<Boolean> that represents whether the given item is selected or not.
What does the Integer represent? Does anyone have any example code of how this is intended to be used?
Thanks, Rob
There are four methods for
CheckBoxTreeTableCell.forTreeTableColumn
. All of them expect a callback, being theTreeTableColumn
of typeObservableValue<Boolean>
, or just aTreeTableColumn
of typeBoolean
.In the last case, since you already provide the column, when the
updateItem
method is called for a given index to render the checkbox, its selected state is found at that position.While on the methods with the callbacks, to find the selected state for a given index, a
call
to that index is made.This is a very simple use case of both situations. You can see how the callback use the index to go into the collection and retrieve the status:
where:
I think you want to use forTreeTableColumn(TreeTableColumn column).