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

ListView scrollTo() is broken after fix for JDK-8089589

    XMLWordPrintable

Details

    • generic
    • generic

    Backports

      Description

        ADDITIONAL SYSTEM INFORMATION :
        OS - Windows 10 20H2
        Java (JRE) - 11.0.12
        JavaFX - 17.0.1

        A DESCRIPTION OF THE PROBLEM :
        The "scrollTo" feature on ListView is no longer working on JavaFX 17 or 18 early access builds.
        It works fine if I downgrade to JavaFX16
        It neither sorts by index nor by the object

        countriesListView.scrollTo(lastSelectedIndex);

        REGRESSION : Last worked in openjfx 16

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Create a list view in JavaFX
        Insert 15-20 elements, such that you get a scrollpane on it.
        invoke
        listView.scrollTo(10); //Scroll to 10th index i.e. 11th element

        Launch the program and you'd notice the list didn't scroll to the selected element (scrollTo doesn't work)

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        List View should scroll down to the given index/element in listView.scrollTo() method call.
        ACTUAL -
        listView does not scrollTo the given index/element and the focus is always at the beginning of the listView i.e. the first element

        ---------- BEGIN SOURCE ----------

        import javafx.application.Application;
        import javafx.scene.Scene;
        import javafx.scene.control.ListView;
        import javafx.scene.layout.HBox;
        import javafx.stage.Stage;

        public class ListClass extends Application {

                @Override
                public void start(Stage primaryStage) throws Exception {
                    primaryStage.setTitle("ListView ScrollTest");

                    ListView listView = new ListView();

                    listView.getItems().add("Item 1");
                    listView.getItems().add("Item 2");
                    listView.getItems().add("Item 3");
                    listView.getItems().add("Item 4");
                    listView.getItems().add("Item 5");
                    listView.getItems().add("Item 6");
                    listView.getItems().add("Item 7");
                    listView.getItems().add("Item 8");
                    listView.getItems().add("Item 9");
                    listView.getItems().add("Item 10");
                    listView.getItems().add("Item 11");
                    listView.getItems().add("Item 12");
                    listView.getItems().add("Item 13");
                    listView.getItems().add("Item 14");
                    listView.getItems().add("Item 15");
                    listView.getItems().add("Item 16");
                    listView.getSelectionModel().select(10);
                    listView.scrollTo(10);

                    HBox hbox = new HBox(listView);
                    Scene scene = new Scene(hbox, 300, 120);
                    primaryStage.setScene(scene);
                    primaryStage.show();
                }

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

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

        CUSTOMER SUBMITTED WORKAROUND :
        Use JavaFX 16

        FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

                jvos Johan Vos
                webbuggrp Webbug Group
                Votes:
                2 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: