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

SelectionModel.selectedIndex change listener always returns old value as -1

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: fx2.0
    • Fix Version/s: 8
    • Component/s: javafx
    • Labels:

      Description

      Try using a callback such as the following, and observe that the old value is always -1

      listView.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
          public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
              System.out.println("change listener: " + t + " -> " + t1);
          }
      });

      Workaround: Developer can locally record the old value of the selected index within the ChangeListener anonymous inner class.

        Attachments

          Activity

            People

            Assignee:
            jgiles Jonathan Giles
            Reporter:
            jgiles Jonathan Giles
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: