RFR: 8344981: [REDO] JDK-6672644 JComboBox still scrolling if switch to another window and return back [v3]

Harshitha Onkar honkar at openjdk.org
Fri Feb 14 19:34:11 UTC 2025


On Tue, 11 Feb 2025 19:16:36 GMT, Damon Nguyen <dnguyen at openjdk.org> wrote:

>> Redo for JComboBox infinite scrolling issue. The issue is that when a scrollbar is clicked and held, if the user switches focus (ex: ALT+TAB) while scrolling, when focused is returned to the scrolling application, the JComboBox will still be scrolling even though nothing it being clicked.
>> 
>> Previously, a KeyboardFocusListener was added to determine the focus. However, there was a memory leak on Windows and Ubuntu. This current implementation uses the current FocusManager and is overall a cleaner, simpler approach.
>> 
>> CI testing is green on all platforms.
>
> Damon Nguyen has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Update copyright year
>  - Change fix to use isShowing. Update test to auto.

Automated test looks good. Tested on Windows and Ubuntu, fix works as expected.

Minor suggestions provided inline.

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java line 1616:

> 1614:                 ((Timer)e.getSource()).stop();
> 1615:                 buttonListener.handledEvent = false;
> 1616:                 scrollbar.setValueIsAdjusting(false);

scrollbar.setValueIsAdjusting() is actually used for scroll thumb drag.
Not sure why it is also used on Ln# 1612, but no harm in resetting it to false.

test/jdk/javax/swing/JComboBox/JComboBoxScrollFocusTest.java line 81:

> 79: 
> 80:     static Rectangle getOnScreenBoundsOnEDT(Component component)
> 81:             throws InterruptedException, TimeoutException, ExecutionException {

Suggestion:

            throws Exception {

test/jdk/javax/swing/JComboBox/JComboBoxScrollFocusTest.java line 92:

> 90:     private static int getScrollbarValue()
> 91:             throws InterruptedException, InvocationTargetException,
> 92:             ExecutionException, TimeoutException {

Can be simplified to throw generic exception 
Suggestion:

            throws Exception {

test/jdk/javax/swing/JComboBox/JComboBoxScrollFocusTest.java line 155:

> 153:         }
> 154:     }
> 155: }

EOF new line missing here

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

Marked as reviewed by honkar (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/23451#pullrequestreview-2618614251
PR Review Comment: https://git.openjdk.org/jdk/pull/23451#discussion_r1956621302
PR Review Comment: https://git.openjdk.org/jdk/pull/23451#discussion_r1956612535
PR Review Comment: https://git.openjdk.org/jdk/pull/23451#discussion_r1956612263
PR Review Comment: https://git.openjdk.org/jdk/pull/23451#discussion_r1956610978


More information about the client-libs-dev mailing list