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

ListView selectionModel selectedIndices ListIterator nextIndex broken

    XMLWordPrintable

Details

    • x86
    • windows_8

    Description

      FULL PRODUCT VERSION :
      java version "1.8.0_66"
      Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
      Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.10586]

      A DESCRIPTION OF THE PROBLEM :
      The ListIterator of the selectedIndices list of the SelectionModel of ListView returns a incorrect index, if nextIndex() is called.

      This causes e.g. a FilteredList with null as Predicate to remain empty and even for multiple selection it remains empty, if the elements are selected one by one using the mouse.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the source code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      0 printed to System.out
      ACTUAL -
      1 printed to System.out

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.application.Platform;
      import javafx.collections.FXCollections;
      import javafx.scene.control.ListView;
      import javafx.stage.Stage;

      public class Test extends Application {
          public void start(Stage s) {}

          public static void main(String[] args) {
              ListView<String> list = new ListView<>(FXCollections.observableArrayList("1"));
              list.getSelectionModel().select(0);
              int nextIndex = list.getSelectionModel().getSelectedIndices().listIterator().nextIndex();
              System.out.println(nextIndex);
              Platform.exit();
          }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Reimplement classes/methods that require correct results. (E.g. FilteredList)

      Attachments

        Activity

          People

            arapte Ambarish Rapte
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: