I have the same problem as the OP. In addition, I want to bind the value displayed in the TreeItem to an object property. This is not complete, but I am experimenting with the following helper class, where I pass the "custom object" (or element) to be referenced in the TreeItem, and valueProperty (which, in my case, is the property of the element) to bind to the value of the TreeItem. value.
final class BoundTreeItem<B, T> extends TreeItem<T> { public BoundTreeItem(B item, Property<T> valueProperty) { this(item, valueProperty, null); } public BoundTreeItem(B item, Property<T> valueProperty, Node graphic) { super(null, graphic); itemProperty.set(item); this.valueProperty().bindBidirectional(valueProperty); } public ObjectProperty<B> itemProperty() { return itemProperty; } public B getItem() { return itemProperty.get(); } private ObjectProperty<B> itemProperty = new SimpleObjectProperty<>(); }
source share