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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8u20
    • 8u20
    • javafx
    • None

      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

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

              Created:
              Updated:
              Resolved:
              Imported: