From 877f2dea32a704d1c764ba0094ea5cec0b6eae5c Mon Sep 17 00:00:00 2001 From: Pavel Porvatov Date: Fri, 15 Jul 2011 14:43:22 +0400 Subject: [PATCH] 4909150: WindowsTreeUI can cause NullPointerException occasionally Reviewed-by: alexp --- .../swing/plaf/windows/WindowsTreeUI.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java index 0b322a5e145..1fbc2254d99 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java +++ b/jdk/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; + 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)); } } }