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

TreeView selection issues

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 8
    • 7u6
    • javafx
    • JDK 7u11 b21

    Description

      Steps:
      1. run following code;
      2. Expand "Second parent"
      3. Select "Child 2"
      4. Expand "First parent"

      You get
      a) visual selection for child 2.
      b) getSelectionModel().getSelectedItem() will return null
      c) visual focus for second parent. It seems to be expected behavior

      public class TreeViewSelection extends Application {
          @Override
          public void start(Stage stage) throws Exception {
             final TreeView tree;
              stage.setScene(new Scene(new Group(tree = TreeViewBuilder.create().showRoot(false)
                      .root(TreeItemBuilder.create()
                              .children(
                                      TreeItemBuilder.create().value("First parent")
                                              .children(new TreeItem("Child 1")).build(),
                                      TreeItemBuilder.create().value("Second parent")
                                              .children(new TreeItem("Child 2")).build()
                              ).build())
                      .build())));
              tree.getSelectionModel().selectedItemProperty().addListener(new InvalidationListener() {
                  @Override
                  public void invalidated(Observable observable) {
                      System.out.println(tree.getSelectionModel().getSelectedItem());
                  }
              });
              stage.show();
          }

          public static void main(String[] args) {
              launch(args);
          }
      }


      //////output
      TreeItem [ value: Child 2 ]
      null

      Attachments

        Activity

          People

            jgiles Jonathan Giles
            anazarov Andrey Nazarov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: