4909150: WindowsTreeUI can cause NullPointerException occasionally
authorrupashka
Fri, 15 Jul 2011 14:43:22 +0400
changeset 10093 1e497500c05f
parent 10092 aff525ea8b17
child 10094 f211e6ca5dff
4909150: WindowsTreeUI can cause NullPointerException occasionally Reviewed-by: alexp
jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java	Tue Jul 12 11:41:50 2011 +0400
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java	Fri Jul 15 14:43:22 2011 +0400
@@ -81,19 +81,22 @@
             else {
                 Rectangle   beginRect = getPathBounds(tree, getPathForRow
                                                       (tree, beginRow));
-                Rectangle   testRect = beginRect;
-                int         beginY = beginRect.y;
-                int         maxY = beginY + visRect.height;
+                if (beginRect != null) {
+                    Rectangle   testRect = beginRect;
+                    int         beginY = beginRect.y;
+                    int         maxY = beginY + visRect.height;
 
-                for(int counter = beginRow + 1; counter <= endRow; counter++) {
-                    testRect = getPathBounds(tree,
-                                             getPathForRow(tree, counter));
-                    if((testRect.y + testRect.height) > maxY)
-                        counter = endRow;
+                    for(int counter = beginRow + 1; counter <= endRow; counter++) {
+                        testRect = getPathBounds(tree,
+                                                 getPathForRow(tree, counter));
+                        if(testRect != null && (testRect.y + testRect.height) > maxY) {
+                            counter = endRow;
+                        }
+                    }
+                    tree.scrollRectToVisible(new Rectangle(visRect.x, beginY, 1,
+                                                      testRect.y + testRect.height-
+                                                      beginY));
                 }
-                tree.scrollRectToVisible(new Rectangle(visRect.x, beginY, 1,
-                                                  testRect.y + testRect.height-
-                                                  beginY));
             }
         }
     }