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

Graphic property of TreeItem is still visible after collapsing tree

XMLWordPrintable

    • b96
    • 9
    • x86_64
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Windows 7 x64
      java version 10.0.2

      A DESCRIPTION OF THE PROBLEM :
      When you collapse root tree - you will see that child treeItem graphics are still visible.

      REGRESSION : Last worked in version 8u181

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      To reproduce just launch class below and expand/collapse root tree - you will see that child treeItem graphics are still visible.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      After collapsing root tree graphics of child treeItems should disappear

      ---------- BEGIN SOURCE ----------
      package com.idc.shellexplorer;

      import javafx.application.Application;
      import javafx.beans.property.ReadOnlyStringWrapper;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.scene.control.TreeTableColumn;
      import javafx.scene.control.TreeTableColumn.CellDataFeatures;
      import javafx.scene.control.TreeItem;
      import javafx.scene.control.TreeTableView;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.Rectangle;
      import javafx.stage.Stage;
      import javafx.scene.image.ImageView;

      public class TestTreeTableView extends Application {


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

          @Override
          public void start(Stage stage) {
              stage.setTitle("Tree Table View Samples");
              final Scene scene = new Scene(new Group(), 200, 400);
              Group sceneRoot = (Group)scene.getRoot();


              //Creating the root element
              final TreeItem<String> root = new TreeItem<>("Root node", createIcon(Color.GREEN));

              for (int i = 1; i <= 30; i++) {
                  //Creating tree items
                  final TreeItem<String> childNode1 = new TreeItem<>("Child Node " + i);
                  if (i % 2 == 0) {
                      childNode1.setGraphic(createIcon(Color.BLUE));
                  } else {
                      childNode1.setGraphic(createIcon(Color.RED));
                  }

                  for (int j = 1; j <= 5; j++) {
                      final TreeItem<String> childChildNode1 = new TreeItem<>("Child child Node " + j);
                      childChildNode1.setGraphic(createIcon(Color.BLACK));
                      childNode1.getChildren().add(childChildNode1);
                  }
                  root.getChildren().add(childNode1);
              }

              //Creating a column
              TreeTableColumn<String,String> column = new TreeTableColumn<>("Column");
              column.setPrefWidth(200);

              //Defining cell content
              column.setCellValueFactory((CellDataFeatures<String, String> p) ->
                      new ReadOnlyStringWrapper(p.getValue().getValue()));

              //Creating a tree table view
              final TreeTableView<String> treeTableView = new TreeTableView<>(root);
              treeTableView.getColumns().add(column);
              treeTableView.setPrefWidth(200);
              treeTableView.setShowRoot(true);
              sceneRoot.getChildren().add(treeTableView);
              stage.setScene(scene);
              stage.show();
          }

          private ImageView createIcon(Color color) {
              return new ImageView(new Rectangle(12, 12, color).snapshot(null, null));
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


            pmangal Priyanka Mangal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: