RFR: 8359599: Calling refresh() for all virtualized controls recreates all cells instead of refreshing the cells

Kevin Rushforth kcr at openjdk.org
Mon Jun 16 14:20:34 UTC 2025


On Sun, 15 Jun 2025 14:23:27 GMT, Marius Hanl <mhanl at openjdk.org> wrote:

> When calling `refresh()` on virtualized Controls (`ListView`, `TreeView`, `TableView`, `TreeTableView`), all cells will be recreated completely, instead of just refreshing them.
> 
> This is because `recreateCells()` of the `VirtualFlow` is called when `refresh()` was called. This is not needed, since refreshing the cells can be done much cheaper with `rebuildCells()`.
> 
> This will reset all cells (`index = -1`), add them to the pile and fill them back in the viewport with an index again. This ensures `updateItem()` is called.
> 
> The contract of `refresh()` is also a big vague, stating:
> 
> Calling {@code refresh()} forces the XXX control to recreate and repopulate the cells 
> necessary to populate the visual bounds of the control.
> In other words, this forces the XXX to update what it is showing to the user. 
> This is useful in cases where the underlying data source has changed in a way that is not observed by the XXX itself.
> 
> 
> As written above, recreating is not needed in order to fulfull the contract of updating what is shown to the user in case the underlying data source changed without JavaFX noticing (e.g. calling a normal Setter without any Property and therefore listener involved).

This is a risky change and will need to be carefully tested.

Reviewers: @andy-goryachev-oracle @johanvos

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1830#issuecomment-2976845612


More information about the openjfx-dev mailing list