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

Selecting TreeItem programatically expands collapsed Items

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8u20
    • 8
    • javafx
    • Windows 7 x64 with Java 8 b128 x64

    Description

      Hello,

      when a TreeView contains some elements, and one of the elements is set to be not expaneded, selecting that element using getSelectionModel.select() expands that element.

      Sample code:



      package bugreports;

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

      public class TreeViewExpansionBug extends Application
      {
      @Override
      public void start(final Stage primaryStage)
      {
      final TreeItem<String> a = new TreeItem<>("a");
      final TreeItem<String> b = new TreeItem<>("b");

      final TreeItem<String> middle = new TreeItem<>("middle");
      middle.getChildren().addAll(a, b);

      final TreeItem<String> root = new TreeItem<>("root");
      root.getChildren().add(middle);
      root.setExpanded(true);

      final TreeView<String> view = new TreeView<>();
      view.setRoot(root);

      final Button select = new Button("select");
      select.setOnAction(e -> view.getSelectionModel().select(middle));

      final BorderPane pane = new BorderPane();
      pane.setCenter(view);
      pane.setBottom(select);

      primaryStage.setScene(new Scene(pane));
      primaryStage.show();
      }

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


      Steps to reproduce:
      1) Launch. Now you see the nodes root and middle, with middle being collapsed
      2) click on button select. Now middle, is selected, but also expanded

      Attachments

        Activity

          People

            msladecek Martin Sládeček
            cmuthingjfx Clemens Muthing (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: