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

ScrollBar content moves toward-backward during edit.




      When you scroll to the middle of a grid, and you start editing some cells, the scrollbar content is moving up little by little.
      See attached video.

      Steps to reproduce:
      1) Run this sample:
      import javafx.application.Application;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.geometry.Insets;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableRow;
      import javafx.scene.control.TableView;
      import javafx.scene.control.cell.PropertyValueFactory;
      import javafx.scene.control.cell.TextFieldTableCell;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.Priority;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;
      import javafx.util.Callback;

      public class TableViewRowHeight extends Application {

          private TableView<Person> table = new TableView<>();
          private final ObservableList<Person> data = FXCollections.observableArrayList();
          final HBox hb = new HBox();

          public static void main(String[] args) {

          public void start(Stage stage) {
              for (int i = 0; i < 100; ++i) {
                  data.add(new Person("Row " + i));

              stage.setTitle("Table View Sample");


              TableColumn firstNameCol = new TableColumn("First Name");
                      new PropertyValueFactory<Person, String>("firstName"));

              table.setRowFactory(new Callback<TableView<Person>, TableRow<Person>>() {
                  public TableRow<Person> call(TableView<Person> p) {
                      return new TableRow<Person>() {
                          protected double computePrefHeight(double width) {
                              return getIndex() > 5 ? 150 : 24;


              final Button goToCell = new Button("Go to cell 50");
              goToCell.setOnAction(new EventHandler<ActionEvent>() {
                  public void handle(ActionEvent e) {

              final VBox vbox = new VBox();
              vbox.setPadding(new Insets(10, 0, 0, 10));
              HBox hbox = new HBox(table);
              HBox.setHgrow(table, Priority.ALWAYS);
              vbox.getChildren().addAll(goToCell, hbox);
               VBox.setVgrow(hbox, Priority.ALWAYS);
              Scene scene = new Scene(vbox);


          public static class Person {

              private final SimpleStringProperty firstName;

              private Person(String fName) {
                  this.firstName = new SimpleStringProperty(fName);

              public String getFirstName() {
                  return firstName.get();

              public void setFirstName(String fName) {

      2) Click on the "Go to cell 50" button
      3) Double click on cell 52

      Actual behavior:
      The content is moved little by little toward the top

      Expected behavior:
      The content stays still.

      This is a regression introduced in OpenJFX 17 by JDK-8089589. When we edit a cell, the VirtualFlow is trying to compute an estimated height of the whole content based of a few cell. At each iteration, it adds 2 more cells.
      My fifth first cell height are 24px and the rest is 150px. Therefore, each time, the content estimation is growing a little by little, causing the scrollbar content to adjust.

      The new API is completely private or package protected, therefore, I do not have any solution or work-around for this issue.


          Issue Links



              jvos Johan Vos
              shadzic Samir Hadzic
              0 Vote for this issue
              2 Start watching this issue