RFR: 8364146: JList getScrollableUnitIncrement return 0 [v3]
Prasanta Sadhukhan
psadhukhan at openjdk.org
Fri Sep 5 08:19:16 UTC 2025
On Fri, 22 Aug 2025 22:16:48 GMT, Phil Race <prr at openjdk.org> wrote:
> And if the rectangle you pass in has a y that is = the height of the list, then scrolling in a positive direction also returns 0.
> If it is GREATER than the height, then I get back a negative increment !
I tried
Rectangle cell = list.getCellBounds(1, data.length);
cell.y = list.getHeight() + 10;
int unit = list.getScrollableUnitIncrement(
cell,
SwingConstants.VERTICAL,
-1);
System.out.println("Scrollable unit increment: " + unit);
and I get 117 in upward (-1) direction and -99 in downward (1) direction..
so it seems `getScrollableUnitIncrement` finds from `locationToIndex` that it's last row so `r.y` points to TOP of last cell (90) but `visibleRect.y` points to height past the last cell(207) so it has to backtrack -99 pixels [last cell height=18 - (207-90) = 18-117] logically but I guess we need to restrict it to 0 since there is no incremental scrolling that can be done
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26500#issuecomment-3257481618
More information about the client-libs-dev
mailing list