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

[TreeView] Focus doesn't follow the selection after adding children.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u20
    • Fix Version/s: 8u20
    • Component/s: javafx
    • Labels:
      None

      Description

      Start HelloTreeView.
      Select "Child Node 4".
      Press "Add child To Child Node 2" button.
      Press triangle to open "Child Node 2"
      Note that the selection remains on Child Node 4, but focus moves to Child Node 5.
      Adding this code at the end of buildSimpleTab method
              treeView.getFocusModel().focusedIndexProperty().addListener((observable, oldValue, newValue) -> {
                  System.out.println("focusedIndex: " + oldValue + " to " + newValue);
              });
      reveals this log:
      SelectedIndex: 4
      focusedIndex: -1 to 4
      SelectedIndices: [4], removed: [], addedFrom: 0, addedTo: 1
      focusedIndex: 4 to 5 // after button press
      SelectedIndex: 5 // after triangle press
      SelectedIndices: [5], removed: [], addedFrom: 0, addedTo: 1
      focusedIndex: 5 to 6

        Attachments

          Activity

            People

            Assignee:
            jgiles Jonathan Giles
            Reporter:
            vadim Vadim Pakhnushev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: