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

FixedHeightLayoutCache.setExpandedState throws NPE

XMLWordPrintable

    • 1.2.2
    • sparc
    • solaris_2.5



      Name: sdC67446 Date: 12/23/98


      The method FixedHeightLayoutCache.setExpandedState(TreePath path,
      boolean state) throws NullPointerException for the root 'path' and
      'state' == false.

      The doc says:
      --------------------------------------------------

      public void setExpandedState(TreePath path,
                                   boolean isExpanded)

             Marks the path path expanded state to isExpanded.
             Overrides:
                    setExpandedState in class AbstractLayoutCache

      The test demonstrating the bug:
      -----------------Test.java------------------------
      import javax.swing.tree.*;

      public class Test {

          /* create the TreeModel of deep 1 with specified num of children */
          public static DefaultTreeModel getTreeModelILike(int childrenCount) {
      DefaultMutableTreeNode root =
      new DefaultMutableTreeNode("root");

      for (int i = 0; i < childrenCount; i++) {
      DefaultMutableTreeNode child =
      new DefaultMutableTreeNode("root.child"+i);
      root.insert(child,i);
      }
      return new DefaultTreeModel(root);
          }

          public static void main(String[] args) {
      FixedHeightLayoutCache fhlc = new FixedHeightLayoutCache();
      fhlc.setModel(getTreeModelILike(3));
      fhlc.setRootVisible(true);
      TreePath path = fhlc.getPathForRow(0);
      System.out.println("path="+path);
      System.out.println("getExpandedState("+path+")="+fhlc.getExpandedState(path));
      fhlc.setExpandedState(path,false);
      System.out.println("getExpandedState("+path+")="+fhlc.getExpandedState(path));
          }
      }

      ---------Output from the test---------------------
      path=[root]
      getExpandedState([root])=true
      Exception in thread "main" java.lang.NullPointerException
      at javax.swing.tree.FixedHeightLayoutCache$FHTreeStateNode.collapse(Compiled Code)
      at javax.swing.tree.FixedHeightLayoutCache.setExpandedState(Compiled Code)
      at Test.main(Compiled Code)


      --------------------------------------------------
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            sdmitriesunw Sergei Dmitriev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: