This content has been marked as final. Show 4 replies
This sounds like a bad bug! Can you please report it here and I'll take a look: http://javafx-jira.kenai.com
Turns out this is happening only when I use a single ImageView instance for every TreeItem. I finally noticed that the pattern is that the last visible TreeItem to which the icon was attached is the only one that displays the icon, so it changes as I scroll or expand/collapse. Very weird.
When I changed the code to create a new ImageView instance for each TreeItem (while still using a single Image instance passed to each ImageView ctor), all the icons appear and work fine.
I'll put in a bug report at the link posted above.
This is not a bug then. One of the fundamental principles of the JavaFX scenegraph is that a node (in this case an ImageView) can only be in one place in a scenegraph at once. Your approach of creating a new ImageView node (based on a single Image) is the right way to go.
Ok, but there sure seems like there's a bug in there somewhere when all the TreeItems leave room for the icon but only one displays it. I'd say that behavior is at least surprising (and confusing). Might be better to throw an error when a node is used in more than one place, IMHO.