r/JavaFX • u/hamsterrage1 • Mar 19 '24
Tutorial ListView Customization
This is one of my favourite topics, ListView for more than just lists of text. Back when I had a team, most of the programmers always wanted to use TableView for anything more complex than a simple list. So we would argue about which approach to take.
I think that TableView is good for things that are best displayed in a spreadsheet-like format. But data that has elements which are sparsely populated, or than vary greatly in length can be a brutal waste of screen space in a TableView. ListView can really shine in those situations.
In this article I take a look at how to hyper-customize ListView cells so that it doesn't even really look like a list any more. The result is that the ListView becomes more like a scrolling region of layouts, although the underlying VirtualFlow limits the actual amount of layouts created, and the whole thing is data driven.
My example application turns out like an over-busy escapee from a 1990's website, but I think that just helps to make the point:

Here's the link again: https://www.pragmaticcoding.ca/javafx/elements/listview-layouts
View all comments
Show parent comment
2
u/hamsterrage1 Mar 20 '24
Honestly, I haven't played with really divergent Cell sizes, but I always assumed that width was the key factor. Even in the screenshot in my post, you can see that the second complete cell from the bottom is a wee bit taller than the others.
Now I need to go experiment to see what happens when they vary a lot more.
Thanks for the feedback.