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?
javafx.scene.control.ListView doesn't support such functionality.
Given that you are just putting images inside you may want to just use
TilePane to show them.
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.
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/