2005-08-12  Lillian Angel  <[EMAIL PROTECTED]>

        * javax/swing/plaf/basic/BasicTreeUI.java
        (getCellLocation): Added in a check to make sure the node has 
        children.
        Fixed loop to use post-increment.
        (paintRecursive): Fixed loop to use post-increment.
        (paintControlIcons): Likewise.
        (getNextNode): Fixed check to make sure that node has children.
        (getPreviousSibling): Added in check to make sure index is in 
        correct range.

Index: javax/swing/plaf/basic/BasicTreeUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTreeUI.java,v
retrieving revision 1.59
diff -u -r1.59 BasicTreeUI.java
--- javax/swing/plaf/basic/BasicTreeUI.java	10 Aug 2005 15:04:15 -0000	1.59
+++ javax/swing/plaf/basic/BasicTreeUI.java	12 Aug 2005 17:51:32 -0000
@@ -2620,7 +2620,8 @@
       }
 
     if (!mod.isLeaf(startNode)
-        && tree.isExpanded(new TreePath(getPathToRoot(startNode, 0))))
+        && tree.isExpanded(new TreePath(getPathToRoot(startNode, 0))) 
+        && mod.getChildCount(startNode) > 0)
       {
         Object child = mod.getChild(startNode, 0);
         if (child != null)
@@ -2711,7 +2712,7 @@
         int max = mod.getChildCount(curr);
         if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0))))
           {
-            for (int i = 0; i < max; ++i)
+            for (int i = 0; i < max; i++)
               {
                 int indent = indentation + rightChildIndent;
                 if (!isRootVisible && depth == 0)
@@ -2783,7 +2784,7 @@
             if (!node.equals(mod.getRoot()))
               ei.paintIcon(tree, g, indentation - rightChildIndent - 3, h);
 
-            for (int i = 0; i < max; ++i)
+            for (int i = 0; i < max; i++)
               {
                 int indent = indentation + rightChildIndent;
                 if (depth == 0 && !tree.isRootVisible())
@@ -2930,7 +2931,7 @@
   Object getNextNode(Object curr)
   {
     TreeModel mod = tree.getModel();
-    if (mod.getChildCount(curr) != 0)
+    if (mod.getChildCount(curr) > 0)
       return mod.getChild(curr, 0);
 
     Object node = curr;
@@ -3013,7 +3014,7 @@
 
     int index = mod.getIndexOfChild(parent, node) - 1;
 
-    if (index < 0)
+    if (index < 0 || index >= mod.getChildCount(parent))
       return null;
 
     return mod.getChild(parent, index);
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to