diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java index 0b322a5e1456621e40927dee1d55a84e8f2486fe..1fbc2254d99ce746e5aa79b92d585b4a8b9cdeb6 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java @@ -81,19 +81,22 @@ public class WindowsTreeUI extends BasicTreeUI { else { Rectangle beginRect = getPathBounds(tree, getPathForRow (tree, beginRow)); - 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; + 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 != 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)); } } }