-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
None
-
1.2.0
-
None
-
generic
-
solaris_2.4
When a JList instance is in a JScrollPane and the JScrollPane viewport is
taller than the contents of the list, getLastVisibleIndex will return an
incorrect value of -1. I believe the reason for this is that the logic
for obtaining the last visible index tries to determine the list row that
maps to the location at the bottom of the visible rectangle. Since this
is outside the bounds of the list when the JScrollPane viewport is larger
than the list, the UI returns a -1 because it assumes an invalid location
has been sent to it.
I have attached a small application that places a JList in a JScrollPane.
At the top of the window is a "Debug" button; when you press it, it
println's the results of calls to getFirstVisibleIndex, getLastVisibleIndex,
and getVisibleRowCount. If you resize the application so the JScrollPane
viewport is smaller than the list, the values are valid. When you resize
the application so the JScrollPane viewport is larger than the list,
getLastVisibleIndex is -1.
taller than the contents of the list, getLastVisibleIndex will return an
incorrect value of -1. I believe the reason for this is that the logic
for obtaining the last visible index tries to determine the list row that
maps to the location at the bottom of the visible rectangle. Since this
is outside the bounds of the list when the JScrollPane viewport is larger
than the list, the UI returns a -1 because it assumes an invalid location
has been sent to it.
I have attached a small application that places a JList in a JScrollPane.
At the top of the window is a "Debug" button; when you press it, it
println's the results of calls to getFirstVisibleIndex, getLastVisibleIndex,
and getVisibleRowCount. If you resize the application so the JScrollPane
viewport is smaller than the list, the values are valid. When you resize
the application so the JScrollPane viewport is larger than the list,
getLastVisibleIndex is -1.
- relates to
-
JDK-4193267 JList getLastVisibleIndex
-
- Closed
-