This content has been marked as final. Show 5 replies
Which is the correct way to customize the presentation of an item (e.g., adding a clickable image to it) in this scenario ?Use CSS.
Finally, what if I would like to add not just an image, but a context menu to items in this tree ?See how a TreeView item is made to react to a mouse click as in this example, and on click pop up context menu rather than updating label text:
Might be easier to start with subclassing a standard TreeCell rather than a CheckBoxTreeCell, otherwise review the source code for CheckBoxTreeCell and TreeCell, then make sure that when you override updateItem you aren't doing anything which would mess up the standard functioning of the CheckBoxTreeCell:
Thanks for answering, I will take a look to the internals of the CheckBoxTreeCell to see how can I change the default layout of the item without breaking the check box.
But I have the feeling something in that class is wrong if there is not a straighforward mechanism for customizing the item presentation. It does not seem like an exotic requirement, isn't it ?
I have the feeling something in that class is wrongYou should check the issue tracker:
https://javafx-jira.kenai.com/browse/RT-24666 "Public extensions of TreeCell do not render their item's graphic attribute"
https://javafx-jira.kenai.com/browse/RT-30372 "CheckBoxTreeItem: extra checkbox on Treeview"
https://javafx-jira.kenai.com/browse/RT-30388 "HelloTreeView: checked TreeView aligns children left"
Do you know if the status of "fixed" in the first link means that "setGraphic(...)" should work in JavaFX 8 ?I tried the test code from RT-24666 link and it worked as expected.
I changed the TextFieldTreeCell in the test code to CheckBoxTreeCell and it also rendered the graphic for the CheckBoxTreeCell when it was set, however it did still have the issue RT-30372, so that particular class is still buggy.
Tested on OS X 10.8, Java 8b89