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

JavaFX TreeTableView leaves icons behind when collapsing

XMLWordPrintable

    • x86_64
    • linux

      FULL PRODUCT VERSION :
      Windows:
      java version "1.8.0_92"
      Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
      Java HotSpot(TM) Client VM (build 25.92-b14, mixed mode)

      Linux 1:
      java version "1.8.0_92"
      Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

      Linux 2:
      openjdk version "1.8.0_92"
      OpenJDK Runtime Environment (build 1.8.0_92-b14)
      OpenJDK 64-Bit Server VM (build 25.92-b14, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux [redacted] 4.5.1-1-ARCH #1 SMP PREEMPT Thu Apr 14 19:19:32 CEST 2016 x86_64 GNU/Linux
      Microsoft Windows [Version 6.1.7601]


      A DESCRIPTION OF THE PROBLEM :
      I have a TreeTableView where every node has an icon. Everything works perfectly when I expand the tree, but when I collapse the tree, the icons of the no longer visible items are left behind.

      The rows and the text are removed, but the icons remain "free-floating". In the screenshot you can see the TreeTableView twice, once expanded with the correct text, and once collapsed with only the remaining icons.

      Please see http://stackoverflow.com/questions/36917220/javafx-treetableview-leaves-icons-behind-when-collapsing for screenshots and sample code.

      This code was adapted from Oracle documentation on TreeTableView at https://docs.oracle.com/javase/8/javafx/user-interface-tutorial/tree-table-view.htm

      REGRESSION. Last worked in version 8u73

      ADDITIONAL REGRESSION INFORMATION:
      A user on Stackoverflow reported that the sample code works on 1.8.0_71.

      Please see http://stackoverflow.com/questions/36917220/javafx-treetableview-leaves-icons-behind-when-collapsing for more information

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Please see http://stackoverflow.com/questions/36917220/javafx-treetableview-leaves-icons-behind-when-collapsing for sample code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expected the icons to not be displayed anymore
      ACTUAL -
      The icons were still present, although the rest of the cells was removed

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      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.stage.Stage;
      import javafx.scene.image.Image;
      import javafx.scene.image.ImageView;

      public class TreeTableViewSample extends Application {
          private static final Image icon = new Image(TreeTableViewSample.class.getResourceAsStream("icon.png"));

          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 tree items
              final TreeItem<String> childNode1 = new TreeItem<>("Child Node 1", new ImageView(icon));
              final TreeItem<String> childNode2 = new TreeItem<>("Child Node 2", new ImageView(icon));
              final TreeItem<String> childNode3 = new TreeItem<>("Child Node 3", new ImageView(icon));

              //Creating the root element
              final TreeItem<String> root = new TreeItem<>("Root node", new ImageView(icon));
              root.setExpanded(true);

              //Adding tree items to the root
              root.getChildren().setAll(childNode1, childNode2, childNode3);

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

              //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(152);
              treeTableView.setShowRoot(true);
              sceneRoot.getChildren().add(treeTableView);
              stage.setScene(scene);
              stage.show();
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      When the icon is set using a CellFactory, collapsing works as expected.

            jgiles Jonathan Giles
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: