Reputation: 1895
I would have liked to have the ability to add a CSS class to the TreeItem and then just use a CSS file to give it style. But that is not possible, or is it?
Is there a way to add a class like we can using getStyleClass()?
If not, what is the best way to give individual items a style?
Upvotes: 0
Views: 2515
Reputation:
Use a TreeCellFactory , and in the factory, use a Node and set it's style, either via getStyle, or even better via Node.setStyleClass.
Upvotes: 1
Reputation: 3904
Well... Think outside the box! You can't style treeitem and tablerow because they act basically as a form of containers to other nodes, so set a class for the nodes on your treeitem (or tablerow) and then style them. I'm sorry by the answer, but I can't add comments yet
Upvotes: 1
Reputation: 2707
Best way to give style to items is use of stylesheets, limit use of Node.setStyle.
You may wonder why?
Reason is a performance. Calculate style values are cached. All Nodes that match the same selectors can share the calculculate value.
Upvotes: 1