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

TreeView - Wrong intendation for empty TreeItems

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • fx2.1
    • fx2.1
    • javafx
    • Windows 7, JavaFX 2.1 beta b12

      If there are empty TreeItems and then there is a TreeItem with children outside the visible area, the TreeItems are not intended until I expand the treeItem with children.

      To see, run this code. See, that they are not intended, scroll down, expand TreeItem 19, and notice how TreeItem 1-18 move to their correct position.

      Another issue, I noticed is, that if you expand TreeItem 19 while the scrollbar touches the bottom (scrolled to maximum), TreeItem 19 jumps up by the height of its children. If the scollbar is somewhere in the middle, the expanded item holds its position. Not really a serious bug, but inconsistent behavior.



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


      public class TestApp3 extends Application {
          public static void main(String[] args) throws Exception {
              launch(args);
          }

          public void start(final Stage stage) throws Exception {

              VBox root = new VBox();

              TreeView<String> treeView = new TreeView<String>(new TreeItem<String>());
              treeView.setShowRoot(false);

              for (int i = 0; i < 30; i++) {
                  TreeItem<String> treeItem = new TreeItem<String>();

                  treeItem.setValue("TreeItem " + i);

                  if (i == 19) {
                      for (int j = 0; j < 5; j++) {
                          TreeItem<String> subTreeItem = new TreeItem<String>();
                          subTreeItem.setValue("SubTreeItem" + i + "." + j);
                          treeItem.getChildren().add(subTreeItem);
                      }
                  }

                  treeView.getRoot().getChildren().add(treeItem);
              }


              root.getChildren().add(treeView);
              Scene scene = new Scene(root);
              stage.setScene(scene);
              stage.show();
          }
      }

            jgiles Jonathan Giles
            cschudtjfx Christian Schudt (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: