# HG changeset patch # User alexsch # Date 1354620417 -14400 # Node ID d524ae0f511e63ffb37f9134dab69ec0137c36b7 # Parent 98b268fecedc9b53e2ec70986faab676061e3df9 6671481: NPE at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection Reviewed-by: serb diff -r 98b268fecedc -r d524ae0f511e jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java Fri Nov 30 17:09:05 2012 -0800 +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java Tue Dec 04 15:26:57 2012 +0400 @@ -1941,6 +1941,9 @@ for(int counter = beginRow + 1; counter <= endRow; counter++) { testRect = getPathBounds(tree, getPathForRow(tree, counter)); + if (testRect == null) { + return; + } if((testRect.y + testRect.height) > maxY) counter = endRow; } @@ -2069,7 +2072,7 @@ treeState.invalidatePathBounds(oldPath); updateSize(); } - else { + else if (editingBounds != null) { editingBounds.x = 0; editingBounds.width = tree.getSize().width; tree.repaint(editingBounds); @@ -2114,6 +2117,9 @@ tree.isPathSelected(path), tree.isExpanded(path), treeModel.isLeaf(path.getLastPathComponent()), row); Rectangle nodeBounds = getPathBounds(tree, path); + if (nodeBounds == null) { + return false; + } editingRow = row; @@ -2134,6 +2140,9 @@ // To make sure x/y are updated correctly, fetch // the bounds again. nodeBounds = getPathBounds(tree, path); + if (nodeBounds == null) { + return false; + } } else editorHasDifferentSize = false; @@ -3570,7 +3579,7 @@ if(pressedPath != null) { Rectangle bounds = getPathBounds(tree, pressedPath); - if(e.getY() >= (bounds.y + bounds.height)) { + if (bounds == null || e.getY() >= (bounds.y + bounds.height)) { return; } @@ -3832,6 +3841,10 @@ // And repaint Rectangle newMinBounds = getPathBounds(tree, minPath); + if (minBounds == null || newMinBounds == null) { + return; + } + if (indices.length == 1 && newMinBounds.height == minBounds.height) { tree.repaint(0, minBounds.y, tree.getWidth(),