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

when i try to expand the treeitem,the selectitem's focus changes wrong

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P4
    • None
    • None
    • javafx
    • None

    Description

      the treeview looks like this:
      root
            nodeA
                    leafa
                    leafb
                    leafc
            nodeB
                    leafd
                    leafe
                    leaff

      first,i select leafd,and leafd get the focus.
      then,i try to expand nodeA,this time,leafd and leafb both get the focus.



      the source:

      package test;

      /**

       * Copyright (c) 2008, 2012 Oracle and/or its affiliates.

       * All rights reserved. Use is subject to license terms.

       */

      import javafx.application.Application;

      import javafx.scene.Group;

      import javafx.scene.Scene;

      import javafx.stage.Stage;

      import javafx.scene.control.TreeView;

      import javafx.scene.control.TreeItem;

      import java.util.Arrays;

       

      /**

       * An implementation of the TreeView control displaying an expandable tree root

       * node.

       *

       * @see javafx.scene.control.TreeView

       */

      public class TreeViewSample extends Application {

          private void init(Stage primaryStage) {

              Group root = new Group();

              primaryStage.setScene(new Scene(root));

              final TreeItem<String> treeRoot = new TreeItem<String>("Root node");
              treeRoot.getChildren().addAll(Arrays.asList(

                      new TreeItem<String>("Child Node 1"),

                      new TreeItem<String>("Child Node 2"),

                      new TreeItem<String>("Child Node 3")));

              treeRoot.getChildren().get(1).getChildren().addAll(Arrays.asList(

                      new TreeItem<String>("Child Node 4"),

                      new TreeItem<String>("Child Node 5"),

                      new TreeItem<String>("Child Node 6"),

                      new TreeItem<String>("Child Node 7"),

                      new TreeItem<String>("Child Node 8"),

                      new TreeItem<String>("Child Node 9"),

                      new TreeItem<String>("Child Node 10"),

                      new TreeItem<String>("Child Node 11"),

                      new TreeItem<String>("Child Node 12")));
       

              treeRoot.getChildren().get(2).getChildren().addAll(Arrays.asList(

                      new TreeItem<String>("Child Node 4"),

                      new TreeItem<String>("Child Node 5"),

                      new TreeItem<String>("Child Node 6"),

                      new TreeItem<String>("Child Node 7"),

                      new TreeItem<String>("Child Node 8"),

                      new TreeItem<String>("Child Node 9"),

                      new TreeItem<String>("Child Node 10"),

                      new TreeItem<String>("Child Node 11"),

                      new TreeItem<String>("Child Node 12")));

       

              final TreeView treeView = new TreeView();

              treeView.setShowRoot(true);

              treeView.setRoot(treeRoot);

              treeRoot.setExpanded(true);

       

              root.getChildren().add(treeView);

          }

       

       

          @Override public void start(Stage primaryStage) throws Exception {

              init(primaryStage);

              primaryStage.show();

          }

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

      }


      it is a bug or there is a solution?

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:
                Imported: