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

Vertical ScrollBar for TreeTableView with CONSTRAINED_RESIZE_POLICY does not update after expansion or collapse of item

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • 8u20
    • 8
    • javafx
    • Windows7

      The following example shows that the scrollbar is not updated after an expansion or collapse. Only after a new layout by changing window size, the scrollbar is updated correctly.
      Everything works fine, if the CONSTRAINED_RESIZE_POLICY is not used:

      import java.util.ArrayList;

      import javafx.application.Application;
      import javafx.beans.property.ReadOnlyObjectWrapper;
      import javafx.scene.Scene;
      import javafx.scene.control.TreeItem;
      import javafx.scene.control.TreeTableColumn;
      import javafx.scene.control.TreeTableView;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

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

      @Override
      public void start(Stage primaryStage) {

      TreeTableView<String> ttv = new TreeTableView<String>();
      ttv.setShowRoot(false);

      // comment this out to avoid the bug:
      ttv.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);


      TreeTableColumn<String, String> firstColumn = new TreeTableColumn<String, String>();
      firstColumn.setCellValueFactory((item) -> (new ReadOnlyObjectWrapper<String>(item.getValue()
      .getValue())));

      TreeTableColumn<String, String> secondColumn = new TreeTableColumn<String, String>();
      secondColumn.setCellValueFactory((item) -> (new ReadOnlyObjectWrapper<String>(item.getValue()
      .getValue())));
      ttv.getColumns().addAll(new ArrayList<TreeTableColumn<String, String>>() {
      private static final long serialVersionUID = -6617763546462124289L;
      {
      add(firstColumn);
      add(secondColumn);
      }
      });

      TreeItem<String> treeRootItem = new TreeItem<String>("root");
      treeRootItem.setExpanded(false);
      createTreeItems(treeRootItem);
      ttv.setRoot(treeRootItem);

      StackPane root = new StackPane();
      root.getChildren().add(ttv);

      Scene scene = new Scene(root, 300, 250);
      primaryStage.setScene(scene);
      primaryStage.show();
      }

      private void createTreeItems(TreeItem<String> treeRootItem) {
      for (int i = 0; i < 10; i++) {
      TreeItem<String> childTreeItem = new TreeItem<String>("Child: " + i);
      for (int j = 0; j < 10; j++) {
      childTreeItem.getChildren().add(new TreeItem<String>("Child of Child: "
      + j));
      }
      treeRootItem.getChildren().add(childTreeItem);
      }
      }
      }

            jgiles Jonathan Giles
            jehrkejfx Jens Ehrke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: