This fixes the JTable wrt to the BasicScrollBarUI fix.

2006-08-13  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/JTable.java
        (getScrollableUnitIncrement): Fixed direction. Make it behave
        like the RI.
        (getScrollableBlockIncrement): Fixed direction. Make it behave
        like the RI.

/Roman
Index: javax/swing/JTable.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JTable.java,v
retrieving revision 1.118
diff -u -1 -2 -r1.118 JTable.java
--- javax/swing/JTable.java	24 Jul 2006 10:16:29 -0000	1.118
+++ javax/swing/JTable.java	13 Aug 2006 19:33:10 -0000
@@ -3294,28 +3294,39 @@
    * Get the value of the [EMAIL PROTECTED] #selectionModel} property.
    *
    * @return The current value of the property
    */
   public ListSelectionModel getSelectionModel()
   {
     //Neither Sun nor IBM returns null if rowSelection not allowed
     return selectionModel;
   }
   
   public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
   {
-    if (orientation == SwingConstants.VERTICAL)
-      return visibleRect.height * direction;
+    int block;
+    if (orientation == SwingConstants.HORIZONTAL)
+      {
+        block = visibleRect.width;
+      }
     else
-      return visibleRect.width * direction;
+      {
+        int rowHeight = getRowHeight();
+        if (rowHeight > 0)
+          block = Math.max(rowHeight, // Little hack for useful rounding.
+                           (visibleRect.height / rowHeight) * rowHeight);
+        else
+          block = visibleRect.height;
+      }
+    return block;
   }
 
   /**
    * Get the value of the <code>scrollableTracksViewportHeight</code> property.
    *
    * @return The constant value <code>false</code>
    */
   public boolean getScrollableTracksViewportHeight()
   {
     return false;
   }
   
@@ -3341,37 +3352,30 @@
    * 
    * @param visibleRect the currently visible part of the component.
    * @param orientation the scrolling orientation
    * @param direction the scrolling direction (negative - up, positive -down).
    *          The values greater than one means that more mouse wheel or similar
    *          events were generated, and hence it is better to scroll the longer
    *          distance.
    * @author Audrius Meskauskas ([EMAIL PROTECTED])
    */
   public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation,
                                         int direction)
   {
-    int h = (rowHeight + rowMargin);
-    int delta = h * direction;
-
-    // Round so that the top would start from the row boundary
-    if (orientation == SwingConstants.VERTICAL)
-      {
-        // Completely expose the top row
-        int near = ((visibleRect.y + delta + h / 2) / h) * h;
-        int diff = visibleRect.y + delta - near;
-        delta -= diff;
-      }
-    return delta;
-    // TODO when scrollng horizontally, scroll into the column boundary.
+    int unit;
+    if (orientation == SwingConstants.HORIZONTAL)
+      unit = 100;
+    else
+      unit = getRowHeight();
+    return unit;
   }
 
   /**
    * Get the cell editor, suitable for editing the given cell. The default
    * method requests the editor from the column model. If the column model does
    * not provide the editor, the call is forwarded to the
    * [EMAIL PROTECTED] #getDefaultEditor(Class)} with the parameter, obtained from
    * [EMAIL PROTECTED] TableModel#getColumnClass(int)}.
    * 
    * @param row the cell row
    * @param column the cell column
    * @return the editor to edit that cell

Reply via email to