RFR: 8364146: JList getScrollableUnitIncrement return 0 [v5]

Tejesh R tr at openjdk.org
Wed Oct 22 06:18:04 UTC 2025


On Mon, 6 Oct 2025 06:39:10 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> It seems JList.getScrollableUnitIncrement can sometime return 0 instead of positive number which is not specified in the javadoc which can lead to confusion. Clarified javadoc as to when it can return 0.
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Add test

src/java.desktop/share/classes/javax/swing/JList.java line 2534:

> 2532:                     Rectangle r = getCellBounds(row, row);
> 2533:                     return (r == null) ? 0 :
> 2534:                             (r.height - (visibleRect.y - r.y) < 0) ? 0 : r.height - (visibleRect.y - r.y);

Suggestion:

                            ((r.height - (visibleRect.y - r.y)) < 0) ? 0 : r.height - (visibleRect.y - r.y);

For better readability.

test/jdk/javax/swing/JList/JListTest.java line 47:

> 45:         SwingUtilities.invokeAndWait(() -> {
> 46:             try {
> 47:                 f = new JFrame();

I guess this test can be headless, is there any particular reason for making it headful ?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/26500#discussion_r2450534428
PR Review Comment: https://git.openjdk.org/jdk/pull/26500#discussion_r2450547973


More information about the client-libs-dev mailing list