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

JTree.AccessibleJTree.isAccessibleChildSelected() throws unexpected NPE

XMLWordPrintable

    • beta
    • sparc
    • solaris_2.6
    • Not verified



      Name: aaC67449 Date: 01/14/2000


      The method JTree.AccessibleJTree.isAccessibleChildSelected() throws unexpected
       NPE, when there is no selected child nodes in the JTree.


      See example.
      ------------------------- example ----------------
      import javax.swing.*;
      import javax.swing.tree.*;
      import javax.accessibility.*;

      public class Test {

          public static void main(String argv[]) {
              JTree o = createTree();
              AccessibleSelection c =
                      o.getAccessibleContext().getAccessibleSelection();
              o.expandRow(0);
              //o.addSelectionRow(1); <-- add this line to cover up the problem

              c.isAccessibleChildSelected(0);
              System.out.println("Okey");
       
         }

          public static JTree createTree() {
              DefaultMutableTreeNode root = new DefaultMutableTreeNode(new Integer(0),
                      true);
              JTree tree = new JTree(root);
              tree.setRowHeight(20);

              for (int i = 1; i < 10; i++) {
                  root.add(new DefaultMutableTreeNode(new Integer(i)));
              }
              return tree;
          }

      }

      ------------------------- output ----------------
      Exception in thread "main" java.lang.NullPointerException
              at javax.swing.JTree$AccessibleJTree.isAccessibleChildSelected(JTree.java:3521)
              at Test.main(Test.java:14)

      ======================================================================

            lmonsantsunw Lynn Monsanto (Inactive)
            alisunw Ali Ali (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: