I apologize, I attached the wrong patch before. Here is the updated
version.

On Thu, 2005-07-21 at 10:33 -0400, Lillian Angel wrote:
> 2005-07-21  Lillian Angel  <[EMAIL PROTECTED]>
>         * javax/swing/plaf/basic/BasicTreeUI.java
>         (getPreferredSize): Changed to depend on visible nodes.
>         (mouseClicked): Fixed to keep track of last cell clicked, so 
>       expand/collapse works properly by clicking 2 times on the same 
>       cell.
> 
Index: javax/swing/plaf/basic/BasicTreeUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTreeUI.java,v
retrieving revision 1.45
diff -u -r1.45 BasicTreeUI.java
--- javax/swing/plaf/basic/BasicTreeUI.java	20 Jul 2005 18:59:13 -0000	1.45
+++ javax/swing/plaf/basic/BasicTreeUI.java	21 Jul 2005 14:30:36 -0000
@@ -1322,7 +1322,7 @@
          while (node != null)
          {
             count++;
-            DefaultMutableTreeNode nextNode = node.getNextNode();
+            DefaultMutableTreeNode nextNode = getNextVisibleNode(node);
             if (nextNode != null)
                maxWidth = Math.max(maxWidth, (int) (getCellBounds(0, 0, nextNode)
                      .getWidth()));
@@ -1896,6 +1896,9 @@
       
       /** Number of mouse clicks on a non-leaf */
       private int clickCount = 0;
+      
+      /** The last non-leaf cell that was clicked */
+      private Object lastClicked = null;
 
       /**
        * Constructor
@@ -1943,11 +1946,21 @@
                   && BasicTreeUI.this.tree.isVisible(path))
             {
                if (!cntlClick && !BasicTreeUI.this.isLeaf(row))
-                  clickCount++;
+               {
+                  Object cell = path.getLastPathComponent();
+                  if (lastClicked != null && lastClicked.equals(cell))
+                     clickCount = 2;
+                  else
+                  {
+                     lastClicked = cell;
+                     clickCount = 1;
+                  }
+               }
 
                if (clickCount == 2 || cntlClick == true)
                {
                   clickCount = 0;
+                  lastClicked = null;
                   BasicTreeUI.this.tree.getSelectionModel().clearSelection();
                   if (BasicTreeUI.this.tree.isExpanded(path))
                   {
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to