This fixes some exception in the BasicListUI. Thanks to Christopher for
discussing this on IRC.
2006-01-04 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/plaf/basic/BasicListUI.java
(locationToIndex): Added FIXME about getVisibleRowCount() usage.
Adjusted iteration to not use visibleRowCount and instead iterate
over the real number of elements in cellHeights.
(indexToLocation): Added FIXME about getVisibleRowCount() usage.
Adjusted iteration to not use visibleRowCount and instead iterate
over the real number of elements in cellHeights.
/Roman
Index: javax/swing/plaf/basic/BasicListUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicListUI.java,v
retrieving revision 1.45
diff -u -r1.45 BasicListUI.java
--- javax/swing/plaf/basic/BasicListUI.java 3 Jan 2006 16:47:42 -0000 1.45
+++ javax/swing/plaf/basic/BasicListUI.java 4 Jan 2006 21:37:43 -0000
@@ -1189,6 +1189,9 @@
break;
case JList.HORIZONTAL_WRAP:
// determine visible rows and cells per row
+ // FIXME: We really should not use getVisibleRowCount() here. Please
+ // refer to the (Sun) API docs of JList.setVisibleRowCount() for
+ // details.
int visibleRows = list.getVisibleRowCount();
int cellsPerRow = -1;
int numberOfItems = list.getModel().getSize();
@@ -1244,7 +1247,7 @@
else
{
int posY = 0;
- for (gridY2 = 0; gridY2 <= visibleRows2
+ for (gridY2 = 0; gridY2 <= cellHeights.length
&& posY + cellHeights[gridY2] < location.y;)
{
posY += cellHeights[gridY2];
@@ -1268,6 +1271,9 @@
break;
case JList.HORIZONTAL_WRAP:
// determine visible rows and cells per row
+ // FIXME: We really should not use getVisibleRowCount() here. Please
+ // refer to the (Sun) API docs of JList.setVisibleRowCount() for
+ // details.
int visibleRows = list.getVisibleRowCount();
int numberOfCellsPerRow = -1;
if (visibleRows <= 0)
@@ -1315,7 +1321,7 @@
else
{
locY2 = 0;
- for (int y = 0; y < gridY2; y++)
+ for (int y = 0; gridY2 < cellHeights.length && y < gridY2; y++)
locY2 += cellHeights[gridY2];
}
loc = new Point(locX2, locY2);
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches