Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8369154

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

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • javafx
    • None
    • behavioral
    • minimal
    • There is a small risk that developers were relying on the behavior that all cells were recreated.
    • Java API
    • JDK

      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() {
             ...
           }

            mhanl Marius Hanl
            mhanl Marius Hanl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: