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

TreeView does not allow to add children to hidden root

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: fx2.0
    • Fix Version/s: fx2.0
    • Component/s: javafx
    • Labels:

      Description

      The following code does not work after recent changes:

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

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

          public void start(Stage stage) {
              TreeItem<String> root = new TreeItem<String>();
              add(root, "first"); // works

              TreeView<String> view = new TreeView<String>(root);
              view.setShowRoot(false);
              add(root, "second"); // fails

              stage.setScene(new Scene(view));
              stage.setVisible(true);
          }

          private static void add(TreeItem<String> parent, String child) {
              parent.getChildren().add(new TreeItem<String>(child));
          }
      }

        Attachments

          Activity

            People

            Assignee:
            jgiles Jonathan Giles
            Reporter:
            malenkov Sergey Malenkov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: