In one JavaFx 2 case, i have a TreeView, which is collapsed at certain depth initially. What i'm aiming to achieve is that when one node is being expanded by user click, an action will happend to modified that treeitem property/values.
the problem is that i'm not sure how to refer to that treeitem. I add a listener on each treeitem expanedProperty, but in that ChangeListner method, i can only get old/new values, can't refer back to the treeitem that change event originates.
Can someone help? Thanks a lot.
Yes of course. Try this:
treeItem.expandedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
System.out.println("newValue = " + newValue);
BooleanProperty bb = (BooleanProperty) observable;
System.out.println("bb.getBean() = " + bb.getBean());
TreeItem t = (TreeItem) bb.getBean();
// Do whatever with t
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With