Hi,
While testing the jedit help system (looks pretty now!) I noticed that
BasicTreeUI uses getPathForRow() without checking whether the return
value is null. This patch adds the appropriate guards.
2006-12-03 Mark Wielaard <[EMAIL PROTECTED]>
* javax/swing/plaf/basic/BasicTreeUI.java (paint): Check whether
path[k] is null.
(isLastChild): Return false when path is null.
Committed,
Mark
Index: javax/swing/plaf/basic/BasicTreeUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTreeUI.java,v
retrieving revision 1.154
diff -u -r1.154 BasicTreeUI.java
--- javax/swing/plaf/basic/BasicTreeUI.java 16 Aug 2006 19:28:49 -0000 1.154
+++ javax/swing/plaf/basic/BasicTreeUI.java 3 Dec 2006 16:04:38 -0000
@@ -1587,12 +1587,15 @@
for (int i = startIndex; i <= endIndex; i++, k++)
{
path[k] = treeState.getPathForRow(i);
- isLeaf[k] = treeModel.isLeaf(path[k].getLastPathComponent());
- isExpanded[k] = tree.isExpanded(path[k]);
- bounds[k] = getPathBounds(tree, path[k]);
+ if (path[k] != null)
+ {
+ isLeaf[k] = treeModel.isLeaf(path[k].getLastPathComponent());
+ isExpanded[k] = tree.isExpanded(path[k]);
+ bounds[k] = getPathBounds(tree, path[k]);
- paintHorizontalPartOfLeg(g, clip, insets, bounds[k], path[k], i,
- isExpanded[k], false, isLeaf[k]);
+ paintHorizontalPartOfLeg(g, clip, insets, bounds[k], path[k],
+ i, isExpanded[k], false, isLeaf[k]);
+ }
if (isLastChild(path[k]))
paintVerticalPartOfLeg(g, clip, insets, path[k]);
}
@@ -1600,8 +1603,9 @@
k = 0;
for (int i = startIndex; i <= endIndex; i++, k++)
{
- paintRow(g, clip, insets, bounds[k], path[k], i, isExpanded[k],
- false, isLeaf[k]);
+ if (path[k] != null)
+ paintRow(g, clip, insets, bounds[k], path[k], i, isExpanded[k],
+ false, isLeaf[k]);
}
}
}
@@ -1611,7 +1615,9 @@
*/
private boolean isLastChild(TreePath path)
{
- if (path instanceof GnuPath)
+ if (path == null)
+ return false;
+ else if (path instanceof GnuPath)
{
// Except the seldom case when the layout cache is changed, this
// optimized code will be executed.