I'm looking to create a ListView to populate with a number of images from a specified directory. This is all fine, but annoyingly I can't seem to find a way to get the ListView to wrap, or display in multiple columns (at the moment it's just one image per row which is annoying considering there's no text.)
With Swing's JList this could be accomplished by jList.setLayoutOrientation(JList.HORIZONTAL_WRAP);, but I see no equivalent in JavaFX 2 - am I missing something?
Since I have had the exact same issue, I also investigated in this direction. The TilePane might be a solution if you have only few items, but it will get very slow and consume a lot of resources if you have lots of items. (TilePane does, by design, not support UI virtualisation. That is, reusing/recycling item nodes which are no longer in the viewport.)
Thus, my Idea was to subclass ListView and create a WrappedListView, yet I have stumbled accross a perfect solution: ControlsFX is an Open Source collection of JavaFX controls and it happens to have a GridView Control, supporting virtualisation.
ControlsFX GridView

Here is an overview of all controls in ControlsFX. http://fxexperience.com/controlsfx/features/
For downloading the library, they provide the standard ways such as Maven Dependency in their development site: https://bitbucket.org/controlsfx/controlsfx/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With