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

TreeView's preferred size jumps around

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: fx2.0
    • Fix Version/s: fx2.0
    • Component/s: javafx
    • Environment:

      build 41, win7

      Description

      package main;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.SelectionMode;
      import javafx.scene.control.TreeItem;
      import javafx.scene.control.TreeView;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class Main extends Application {

          TreeView tree_view;
          int itemIndex = 0;

          @Override
          public void start(Stage stage) {
              HBox content = new HBox();
              tree_view = new TreeView();
              tree_view.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
              TreeItem<String> tree_model = new TreeItem<String>("Root");
              for (int i = 0; i < 10; i++) {
                  TreeItem node = new TreeItem("Data item " + i);
                  tree_model.getChildren().add(node);
                  for (int j = 0; j < 100; j++) {
                      node.getChildren().add(new TreeItem("Sub node " + j));
                  }
              }
              tree_view.setRoot(tree_model);
              tree_view.setShowRoot(true);
              //tree_view.setCellFactory(new TextFieldTreeCellFactory<String>());

              content.getChildren().add(tree_view);
              stage.setScene(new Scene(content));
              stage.show();
          }
          public static void main(String[] args) {
              launch(Main.class, args);
          }
      }


      You can use either HBox or VBox. ( I didn't check other containers )

      Try to expand or collapse main window (scene) and at the same time expande or collapse items of the tree.
      Example 1, if you expand tree a few times, collapse it to root node, and try to change size of scene = size of treeView control will jump to decrease.
      Example 2, after first expanding of root node, size of tree view control is not proper.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jgiles Jonathan Giles
                Reporter:
                akirov Alexander Kirov (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: