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

The scrollTo method of the TableView component does not lead to the right place

    XMLWordPrintable

Details

    • generic
    • generic

    Description

      ADDITIONAL SYSTEM INFORMATION :
      I use Windows 10 and it worked fine until version 15.3 of java (ZuluFx from Azul). Since version 15.4, the buggy behavior occurs.

      A DESCRIPTION OF THE PROBLEM :
      When we use the scrollTo method of the TableView graphical component, we normally have to go to the desired row. This worked correctly until version 15.3 but since versions 15.4, the scrollTo leads directly to the top of the TableView and not to the desired row.

      REGRESSION : Last worked in version 15

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a graphical interface with a TableView. Fill the TableView with values. Put a button to scrollTo a row of the TableView (listView.scrollTo(selectedLabelListView);).

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Move the cursor up or down to the selected value
      ACTUAL -
      Automatically moves the cursor of the TableView to the top. Unable to find the selected value (no java error is raised)

      ---------- BEGIN SOURCE ----------
      package testscrollto;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Label;
      import javafx.scene.control.ListView;
      import javafx.scene.layout.BorderPane;
      import javafx.stage.Stage;

      public class Main1 extends Application {

          private Label selectedLabelListView = null;

          public static void main(String[] args) {
              launch(args);
          }

          @Override
          public void start(Stage primaryStage) throws Exception {
              BorderPane root = new BorderPane();
              Button buttonLoadListView = new Button("load listview");
              buttonLoadListView.setFocusTraversable(false);
              ListView<Label> listView = new ListView();
              root.setTop(buttonLoadListView);
              root.setCenter(listView);

              buttonLoadListView.setOnAction(e -> {
                  listView.getItems().clear();
                  for (int i = 0; i < 20; i++) {
                      String stringIndex = Integer.toString(i);
                      String text = "line a\nline b\nline c\nline d_" + stringIndex + "\n";
                      Label label = new Label(text);
                      listView.getItems().add(label);
                      if (i == 10) {
                          selectedLabelListView = label;
                      }
                  }

                  listView.getSelectionModel().select(selectedLabelListView);
                  listView.scrollTo(selectedLabelListView);
              });

              primaryStage.setScene(new Scene(root, 600, 600));
              primaryStage.show();
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
              Platform.runLater(() -> {
                  Thread t = new Thread() {
                  @Override
                  public void run() {
                      try {
                          Thread.sleep(30);
                          listView.getSelectionModel().select(selectedLabelListView);
                          listView.scrollTo(selectedLabelListView);
                      } catch (InterruptedException ex) {
                          Logger.getLogger(FXMLController.class.getName()).log(Level.SEVERE, null, ex);
                      }
                  }
                };
                t.start();
              });

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              pnarayanaswa Praveen Narayanaswamy
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: