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

TreeView: initial focused item incorrect

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8u251, openjfx11, openjfx15
    • Fix Version/s: openjfx17
    • Component/s: javafx

      Description

      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();
          }
      }

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated: