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

TableViewSelectionModel.getSelectedIndex returns value when no row is selected

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • 8u40
    • 8u25
    • javafx
    • Windows 7, Eclipse Luna, jre1.8.0_25

      There seems to be a bug in the TableViewSelectionModel, though the javadocs don't help much on what is to be expected. However in the following code, if I select and then un-select (ctl-click) a row in a I get the following values for the following code:

      private TableView<Person> personTable;
      ....
              personTable.getSelectionModel().selectedItemProperty().addListener(
                      (observable, oldValue, newValue) -> showPersonDetails(newValue));
      .....
      int selectedIndex = personTable.getSelectionModel().getSelectedIndex(); // returns 5 in selectedIndex
      boolean rowSelected = personTable.getSelectionModel().isSelected(selectedIndex); // returns false to rowSelected

      I notice that even if you ctl-click to unselect a row, there is still an outline on the row. Hope this is enough info/contextually clear. Seems straight-forward enough.

            jgiles Jonathan Giles
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: