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

TreeView: initial focused item incorrect

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • jfx11, 8u251, jfx15
    • javafx

      raised in question at SO (https://stackoverflow.com/q/64769593/203657)

      To reproduce, compile and run, note the blue focus marker

      - expected: marker on first item (or no showing at all)
      - actural: marker on second item

      happens if
      - !showRoot
      - treeItems added one-after-the-other to root children (with root already attached to tree)

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.TreeItem;
      import javafx.scene.control.TreeView;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      public class App extends Application {

          @Override
          public void start(Stage stage) {

              TreeView<String> treeView = new TreeView<>();
              TreeItem<String> root = new TreeItem<>("Root");
              treeView.setRoot(root);
              treeView.setShowRoot(false);
              
              root.getChildren().add(new TreeItem<>("Foo"));
              root.getChildren().add(new TreeItem<>("Bar"));
              root.getChildren().add(new TreeItem<>("Baz"));

              var scene = new Scene(new StackPane(treeView), 640, 480);
              stage.setScene(scene);
              stage.show();
          }

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

            aghaisas Ajit Ghaisas
            fastegal Jeanette Winzenburg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: