Summary
refresh() should not all recreate all cells. Instead, they should be refreshed.
Problem
When calling refresh() on virtualized Controls (ListView, TreeView, TableView, TreeTableView), all cells will be recreated completely, instead of just refreshing them.
Recreating all cells is very expensive. We create a lot of garbage, as the old cells are thrown away, we need to create many new cells and update them.
Solution
Instead of recreating all cells, we can refresh them instead.
With this approach, we do not throw cells away, or create new cells. We still update the cells.
Specification
javafx.scene.control.TableView
/**
- * Calling {@code refresh()} forces the TableView control to recreate and
- * repopulate the cells necessary to populate the visual bounds of the control.
+ * Calling {@code refresh()} forces the TableView control to repopulate the
+ * cells necessary to populate the visual bounds of the control.
* In other words, this forces the TableView to update what it is showing to
* the user. This is useful in cases where the underlying data source has
* @since JavaFX 8u60
*/
public void refresh() {
...
}
javafx.scene.control.TreeTableView
/**
- * Calling {@code refresh()} forces the TreeTableView control to recreate and
- * repopulate the cells necessary to populate the visual bounds of the control.
+ * Calling {@code refresh()} forces the TreeTableView control to repopulate the
+ * cells necessary to populate the visual bounds of the control.
* In other words, this forces the TreeTableView to update what it is showing to
* the user. This is useful in cases where the underlying data source has
* @since JavaFX 8u60
*/
public void refresh() {
...
}
javafx.scene.control.ListView
/**
- * Calling {@code refresh()} forces the ListView control to recreate and
- * repopulate the cells necessary to populate the visual bounds of the control.
+ * Calling {@code refresh()} forces the ListView control to repopulate the
+ * cells necessary to populate the visual bounds of the control.
* In other words, this forces the ListView to update what it is showing to
* the user. This is useful in cases where the underlying data source has
* @since JavaFX 8u60
*/
public void refresh() {
...
}
javafx.scene.control.TreeView
/**
- * Calling {@code refresh()} forces the TreeView control to recreate and
- * repopulate the cells necessary to populate the visual bounds of the control.
+ * Calling {@code refresh()} forces the TreeView control to repopulate the
+ * cells necessary to populate the visual bounds of the control.
* In other words, this forces the TreeView to update what it is showing to
* the user. This is useful in cases where the underlying data source has
* @since JavaFX 8u60
*/
public void refresh() {
...
}
- csr of
-
JDK-8359599 Calling refresh() for all virtualized controls recreates all cells instead of refreshing the cells
-
- Open
-