1 Reply Latest reply: Nov 22, 2012 7:48 AM by shakir.gusaroff RSS

    Strange Selection in TreeView


      I am having some issues with TreeView. If attached code is run and the following tried

      1. expand "RootNode"
      2. expand "package B"
      3. select either "B1" or "B2"
      4. expand "package A"

      Then there will be 2 tree items selected, either "B2" and "A3" or "B1" and "A2". The treeview has the selection mode set to single. Does anyone know what is causing this?

      import javafx.application.Application;
      import javafx.stage.Stage;
      import javafx.scene.Scene;
      import javafx.scene.layout.StackPane;
      import javafx.scene.control.TreeView;
      import javafx.scene.control.TreeItem;
      import javafx.scene.control.SelectionMode;
      public class Main extends Application {
           public static void main(String[] args) {
          public void start(Stage primaryStage) throws Exception{
                primaryStage.setTitle("TreeView Test");
           private Scene createScene(){
                StackPane stackPane = new StackPane();
                TreeView treeView = new TreeView<String>();
                return new Scene(stackPane);
           private TreeItem<String> createModel(){
                TreeItem<String> root = new TreeItem<String>("RootNode");
                TreeItem<String> packageA = new TreeItem<String>("package A");
                packageA.getChildren().addAll(new TreeItem<String>("A1"),new TreeItem<String>("A2"),new TreeItem<String>("A3"));
                TreeItem<String> packageB = new TreeItem<String>("package B");
                packageB.getChildren().addAll(new TreeItem<String>("B1"),new TreeItem<String>("B2"),new TreeItem<String>("B3"));
                return root;