This fixes some issues with the JScrollPane. It should now work reasonable
again.
2005-09-30 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/JTable.java
(getScrollableUnitIncrement): Respect the direction argument.
* javax/swing/plaf/basic/BasicScrollPaneUI.java
(VSBChangeListener.stateChanged): Compare ypos with viewPosition.y
instead of viewPosition.x.
(ViewportChangeHandler.stateChanged): Call
syncScrollPaneWithViewport in all cases, not only when the
extents have changed.
(syncScrollPaneWithViewport): Also sync the maximum and value
properties of the scrollbar models with the viewport.
/Roman
Index: javax/swing/JTable.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JTable.java,v
retrieving revision 1.48
diff -u -r1.48 JTable.java
--- javax/swing/JTable.java 21 Sep 2005 18:57:45 -0000 1.48
+++ javax/swing/JTable.java 30 Sep 2005 13:25:07 -0000
@@ -1093,13 +1093,14 @@
// scroll direction.
if (orientation == SwingConstants.VERTICAL)
- return rowHeight;
+ return direction * rowHeight;
else
{
int sum = 0;
for (int i = 0; i < getColumnCount(); ++i)
sum += columnModel.getColumn(0).getWidth();
- return getColumnCount() == 0 ? 10 : sum / getColumnCount();
+ int inc = getColumnCount() == 0 ? 10 : sum / getColumnCount();
+ return direction * inc;
}
}
Index: javax/swing/plaf/basic/BasicScrollPaneUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicScrollPaneUI.java,v
retrieving revision 1.15
diff -u -r1.15 BasicScrollPaneUI.java
--- javax/swing/plaf/basic/BasicScrollPaneUI.java 29 Sep 2005 23:12:39 -0000 1.15
+++ javax/swing/plaf/basic/BasicScrollPaneUI.java 30 Sep 2005 13:25:07 -0000
@@ -121,8 +121,7 @@
JViewport vp = scrollpane.getViewport();
Point viewPosition = vp.getViewPosition();
int ypos = vsb.getValue();
-
- if (ypos != viewPosition.x)
+ if (ypos != viewPosition.y)
{
viewPosition.y = ypos;
vp.setViewPosition(viewPosition);
@@ -159,10 +158,7 @@
JViewport vp = scrollpane.getViewport();
JScrollBar hsb = scrollpane.getHorizontalScrollBar();
JScrollBar vsb = scrollpane.getVerticalScrollBar();
- Dimension extents = vp.getExtentSize();
- if (extents.width != hsb.getModel().getExtent()
- || extents.height != vsb.getModel().getExtent())
- syncScrollPaneWithViewport();
+ syncScrollPaneWithViewport();
}
}
@@ -434,10 +430,18 @@
protected void syncScrollPaneWithViewport()
{
JViewport vp = scrollpane.getViewport();
- JScrollBar vsb = scrollpane.getVerticalScrollBar();
+
+ // Update the horizontal scrollbar.
JScrollBar hsb = scrollpane.getHorizontalScrollBar();
- hsb.getModel().setExtent(vp.getExtentSize().width);
- vsb.getModel().setExtent(vp.getExtentSize().height);
+ hsb.setMaximum(vp.getViewSize().width);
+ hsb.setValue(vp.getViewPosition().x);
+ hsb.setVisibleAmount(vp.getExtentSize().width);
+
+ // Update the vertical scrollbar.
+ JScrollBar vsb = scrollpane.getVerticalScrollBar();
+ vsb.setMaximum(vp.getViewSize().height);
+ vsb.setValue(vp.getViewPosition().y);
+ vsb.setVisibleAmount(vp.getExtentSize().height);
}
/**_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches