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

ChangeListeners attached to TreeItem#expandedProperty() are not notified when child nodes are expanded/collapsed

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: None
    • Fix Version/s: fx2.0
    • Component/s: javafx
    • Labels:

      Description

      According to Jonathan Giles in https://forums.oracle.com/forums/message.jspa?messageID=9929460, tree item events are supposed to bubble up the tree item parent chain. The following code should then print "EXPANDED: .. " when expanding the Item 1 node, which is a child of the root node, but the listener is only notified about changes on the root node:

      import javafx.application.Application;
      import javafx.beans.value.ChangeListener;
      import javafx.beans.value.ObservableValue;
      import javafx.scene.Scene;
      import javafx.scene.control.TreeItem;
      import javafx.scene.control.TreeView;
      import javafx.stage.Stage;

      public class TreeViewTest extends Application {

          public void start(Stage stage) throws Exception {
              TreeItem<String> root = new TreeItem<String>("Root Node");
              TreeItem<String> item1 = new TreeItem<String>("Item 1");
              root.getChildren().add(item1);
              item1.getChildren().add(new TreeItem<String>("Child of Item 1"));

              TreeView<String> treeView = new TreeView<String>(root);

              root.expandedProperty().addListener(new ChangeListener<Boolean>() {
                  public void changed(ObservableValue<? extends Boolean> observableValue, Boolean aBoolean, Boolean aBoolean1) {
                      System.out.println("EXPANDED: " + observableValue.getValue());
                  }
              });

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

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

        Attachments

          Activity

            People

            • Assignee:
              jgiles Jonathan Giles
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: