Our implementation cancels column dragging if the mouse exits the table header area. We have overtried, this is not required (Sun does not).

2006-05-19  Audrius Meskauskas  <[EMAIL PROTECTED]>

   * javax/swing/plaf/basic/BasicTableHeaderUI.java
   (MouseInputHandler.mouseExitted): No nothing there.
   (MouseInputHandler.endDragging): Move column to the
   first/last position if released outside the horizontal
   table range.
Index: javax/swing/plaf/basic/BasicTableHeaderUI.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/plaf/basic/BasicTableHeaderUI.java,v
retrieving revision 1.21
diff -u -r1.21 BasicTableHeaderUI.java
--- javax/swing/plaf/basic/BasicTableHeaderUI.java	7 May 2006 00:13:46 -0000	1.21
+++ javax/swing/plaf/basic/BasicTableHeaderUI.java	19 May 2006 18:49:10 -0000
@@ -199,10 +199,7 @@
      */
     public void mouseExited(MouseEvent e)
     {
-      if (header.getResizingColumn() != null && header.getResizingAllowed())
-        endResizing();
-      if (header.getDraggedColumn() != null && header.getReorderingAllowed())
-        endDragging(null);
+      // Nothing to do.
     }
 
     /**
@@ -363,25 +360,20 @@
     void endDragging(MouseEvent e)
     {
       header.setDraggedColumn(null);
-
-      // Return if the mouse have left the header area while pressed.
-      if (e == null)
-        {
-          header.repaint(draggingHeaderRect);
-          draggingHeaderRect = null;
-          return;
-        }
-      else
-        draggingHeaderRect = null;
+      draggingHeaderRect = null;
 
       TableColumnModel model = header.getColumnModel();
 
       // Find where have we dragged the column.
       int x = e.getX();
       int p = 0;
-      int col = - 1;
+      
+      int col = model.getColumnCount()-1;
       int n = model.getColumnCount();
 
+      // This loop does not find the column if the mouse if out of the 
+      // right boundary of the table header. Then we make this column the
+      // rightmost column.
       Scan: for (int i = 0; i < n; i++)
         {
           p += model.getColumn(i).getWidth();
@@ -391,8 +383,8 @@
               break Scan;
             }
         }
-      if (col >= 0)
-        header.getTable().moveColumn(draggingColumnNumber, col);
+
+      header.getTable().moveColumn(draggingColumnNumber, col);
     }
   }
  

Reply via email to