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

ScrollTo in ListView still doesn't work since VirtualFlow was modified

XMLWordPrintable

    • x86_64
    • windows_10

      ADDITIONAL SYSTEM INFORMATION :
      Java : Zulu FX 21.0.2+101
      Windows 10 x64

      A DESCRIPTION OF THE PROBLEM :
      When I perform a scrollTo in a ListView, the scrollBar doesn't go as far as it should

      REGRESSION : Last worked in version 8u401

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a new project
      Create a listview
      Put the listview in a scene
      Display the scene
      Add items to the listview
      Use scrollTo to go to an item in the listview (if the listview is large enough and you try to scrollTo an item at the bottom of the list, the cursor won't go where it should).

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Let ScrollTo return to the way it worked in Java 8, because there were no bugs back then.

      ACTUAL -
      At the moment, ScrollTo doesn't go low enough. There are still a few pixels and sometimes even a few lines below ScrollTo, even when you ask to Scroll to the last item in the list.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.collections.ListChangeListener;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.ListView;
      import static javafx.scene.input.KeyCode.S;
      import javafx.scene.layout.HBox;
      import javafx.stage.Stage;

      public class Test3 extends Application {

          @Override
          public void start(Stage primaryStage) throws Exception {
              ListView listView = new ListView();

              Scene scene = new Scene(listView, 400, 400);
              primaryStage.setScene(scene);
              primaryStage.show();

              listView.getItems().clear();
              listView.getItems().add("Item 1\nItem 2\nItem 3\nItem 4");
              listView.getItems().add("Item 1\nItem 2\nItem 3\nItem 4");
              listView.getItems().add("Item 1\nItem 2\nItem 3\nItem 4");
              listView.getItems().add("Item 1\nItem 2\nItem 3\nItem 4");
              listView.getItems().add("Item 1\nItem 2\nItem 3\nItem 4");
              listView.getItems().add("Item 1\nItem 2\nItem 3\nItem 4");
              listView.getItems().add("Item 1\nItem 2\nItem 3\nItem 4");
              listView.getItems().add("Item 1\nItem 2\nItem 3\nItem 4");
              listView.getItems().add("Item 1\nItem 2\nItem 3\nItem 4");

              listView.scrollTo(listView.getItems().size() - 1);
          }

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

      ---------- END SOURCE ----------

      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: