Wednesday, 9 April 2014

FX 2.2 to FX 8.0 Part 4 (trees & tables)

Next I checked how TreeView was holding up to the change to FX 8.0  At first everything looked great until I started collapsing and expanding nodes which then made a mess, see the last two items (they shouldn't even be there, but are leftovers from the previous two items):

This is how it looked in FX 2.2:

I figured something had changed in TreeCell so I had a look at the docs and Oracle tutorials (A BIG thank you for those :-) but actually didn't see anything new. So I decided to mimic one of their examples and see what I'd get. In the end it turns out that I wasn't correctly handling empty tree cells. (It maybe that FX 2.2 did this for me, but FX 8.0 sure wasn't.)  So this is very important for TreeCell as well as TableCell where I had a similar problem:

public void updateItem( Object item, boolean empty )
super.updateItem( item, empty );
if ( empty )
setGraphic( null );
setText( null );

setGraphic( itemGraphic );
setText( itemText );

The result after fixing things up:

Next up, where's my carrot ?  Sorry I meant caret .... see part 5.

No comments:

Post a Comment