This content has been marked as final. Show 5 replies
You should use the ListView for this. It virtualizes each of the rows, so even if there are 50,000 rows or 5 million rows, the performance is snappy because it only creates enough nodes to represent the rows that are visible.
The ListView has a "cell factory" which will create a cell for each visible row in the ListView. These cells are reused as you scroll (cell has an update method on it which is called when it needs to repopulate or reconfigure itself based on it representing a new row). You can create your own cell factory which literally can produce a cell that looks however you want.
The JavaFX JavaOne channel is here, although I don't see all of the ones I expected to find.
Thanks for the suggestion, I tried it out and I can create a ListView with 5000 rows, each with 100 buttons in an HBox. It doesn't take a long time to load, but the scrolling is a little slow. Profiling it shows most of the time is spent in JavaFx code (processing CSS, layouts, synchronize scene nodes), with just a portion spent creating the ListViewCells. I fear when we implement more complex controls in each of the cells the scrolling will become even slower.
Another concern I have is interacting with the controls inside each list view cell. It seems I can add context menus and click on the buttons that I added, which is a good thing. On the other hand, we have some advanced requirements like being able to drag and drop activities from one schedule to the other (persisting changes and updating the view), as well as being able to select activities from multiple schedules by dragging a rectangle over them. It would seem these features might be impossible or at least harder to implement by using a list view than by using a canvas.
What do you think?