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

TreeModelEvent doesn't accept " null " for root as Javadoc specifies.

    XMLWordPrintable

Details

    • b96
    • generic
    • generic
    • Verified

    Description

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      The javadoc says

       Notes:

          Like the insertNodeInto method in the DefaultTreeModel class, insertElementAt appends to the Vector when the index matches the size of the vector. So you can use insertElementAt(Integer, 0) even when the vector is empty.
              To create a node changed event for the root node, specify the parent and the child indices as null.



      REGRESSION. Last worked in version 7

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      I have coded the following method to use in my TreeModel when I make changes to the root. It is a DefaultMutableTreeNode, and I want to be able to use " setUserObject(String) " to change the title on the root.

      private void rootChanged() {
      model.fireTreeNodesChanged( tree, new Object[]{root}, null, new Object[]{ root} );
      tree.repaint();
      }

      When I call this method, I see this exception:

      Caused by: java.lang.IllegalArgumentException: Last path component must be non-null
      at javax.swing.tree.TreePath.<init>(TreePath.java:105)
      at javax.swing.event.TreeModelEvent.<init>(TreeModelEvent.java:131)
      at javax.swing.tree.DefaultTreeModel.fireTreeNodesChanged(DefaultTreeModel.java:484)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The documentation says this will work.
      ACTUAL -
      The exception will cause problems in the application's behavior

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Caused by: java.lang.IllegalArgumentException: Last path component must be non-null
      at javax.swing.tree.TreePath.<init>(TreePath.java:105)
      at javax.swing.event.TreeModelEvent.<init>(TreeModelEvent.java:131)
      at javax.swing.tree.DefaultTreeModel.fireTreeNodesChanged(DefaultTreeModel.java:484)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      Attachments

        Issue Links

          Activity

            People

              malenkov Sergey Malenkov (Inactive)
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: