This fixes a small issue in VariableHeightLayoutCache.getBounds(). I
also added a Mauve test to back this up.

2006-10-04  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/tree/VariableHeightLayoutCache.java
        (getBounds): When rect is null, create a new Rectangle.


/Roman

Index: javax/swing/tree/VariableHeightLayoutCache.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/tree/VariableHeightLayoutCache.java,v
retrieving revision 1.17
diff -u -1 -5 -r1.17 VariableHeightLayoutCache.java
--- javax/swing/tree/VariableHeightLayoutCache.java	13 Aug 2006 20:34:03 -0000	1.17
+++ javax/swing/tree/VariableHeightLayoutCache.java	4 Oct 2006 15:34:06 -0000
@@ -327,30 +327,36 @@
   } 
 
   /**
    * Get bounds for the given tree path.
    * 
    * @param path the tree path
    * @param rect the rectangle that will be reused to return the result.
    * @return Rectangle the bounds of the last line, defined by the given path.
    */
   public Rectangle getBounds(TreePath path, Rectangle rect)
   {
     if (path == null)
       return null;
     if (dirty)
       update();
+
+    // The RI allows null arguments for rect, in which case a new Rectangle
+    // is created.
+    if (rect == null)
+      rect = new Rectangle();
+
     Object last = path.getLastPathComponent();
     NodeRecord r = (NodeRecord) nodes.get(last);
     if (r == null)
     // This node is not visible.
       {
         rect.x = rect.y = rect.width = rect.height = 0;
       }
     else
       {
         if (r.bounds == null)
           {
             Rectangle dim = getNodeDimensions(last, r.row, r.depth,
                                               r.isExpanded, rect);
             r.bounds = dim;
           }

Reply via email to