I am using ScrollPane on my JavaFX application. The Scrollpane has TilePane as its content, having thousands of tiles displaying. The scolling is too slow. How to increase the scrolling of the ScrollPane? Thanks.
Update - recommended approach - use a ControlsFX GridView
The ControlsFX, 3rd party JavaFX controls project looks like it has a control which fits your requirements. ControlsFX names the control GridView
. It is a virtualized control as recommended in the solution in this answer, but it comes pre-built so that you don't have to implement your own control or heavily customize ListView to get this behaviour.
Here is a description of the GridView (from it's Javadoc):
A GridView is a virtualised control for displaying getItems() in a visual, scrollable, grid-like fashion. In other words, whereas a ListView shows one ListCell per row, in a GridView there will be zero or more GridCell instances on a single row. This approach means that the number of GridCell instances instantiated will be a significantly smaller number than the number of items in the GridView items list, as only enough GridCells are created for the visible area of the GridView. This helps to improve performance and reduce memory consumption.
Because each GridCell extends from Cell, the same approach of cell factories that is taken in other UI controls is also taken in GridView. This has two main benefits:
- GridCells are created on demand and without user involvement,
- GridCells can be arbitrarily complex. A simple GridCell may just have its text property set, whereas a more complex GridCell can have an arbitrarily complex scenegraph set inside its graphic property (as it accepts any Node).
Obsolete Answer
Rather than using a TilePane for your content, consider using a ListView, which is a virtualized component (e.g. it only creates and renders the nodes which are visible on the screen, rather than all possible nodes). As long as you implement this correctly, it will likely be more efficient than a single large TilePane with thousands of nodes. If ListView doesn't quite fit for you, you can make use of the concepts in the ListViewSkin (you can check out it's application source), to create your own similar virtualized layout for your application (don't expect that to be particularly easy to do though).
how to change the orientation of the ListView?
list.setOrientation(Orientation.HORIZONTAL)
But maybe your question isn't about orientation (I'm now a bit unclear what you are really asking).
Maybe what you want to do is create a normal, vertically oriented ListView of custom Row objects, where each row would consist of a HBox or single row TilePane. Basically, you will need to do more work to get the performance you want, you won't find an out of the box control which will do exactly what you want and perform well.
Unfortunately, providing full example code to completely solve your issue is outside of reasonable scope for a StackOverflow answer.