RFR: 6672644: JComboBox still scrolling if switch to another window and return back [v4]

Damon Nguyen dnguyen at openjdk.org
Tue Nov 12 17:53:33 UTC 2024


On Tue, 12 Nov 2024 17:42:51 GMT, Damon Nguyen <dnguyen at openjdk.org> wrote:

>> src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java line 1244:
>> 
>>> 1242:                     } else if (decrButton.isFocusPainted()) {
>>> 1243:                         decrButton.doClick();
>>> 1244:                     }
>> 
>> Why this doClick block is required?
>
> The scrollbar increase and decrease buttons stay visually clicked down. Trying to change `setFocusPainted` or `setSelected` didn't seem to resolve this. However, adding a `doClick` resolves it and doesn't seem to interfere with the positioning of the scrolled item.
> 
> To be sure, I ran this on CI on all OS's and I didn't run into an issue. I'm open to other suggestions for fixing this visually, but this seemed like the cleanest way to do so.

<img width="394" alt="Screenshot 2024-11-12 at 9 46 35 AM" src="https://github.com/user-attachments/assets/2dafc132-e406-4b5b-a03c-17239c02313b">

Here's an example of the fix WITHOUT the `doClick` on Metal L&F. The JComboBox menu isn't auto-scrolling but the down-arrow button still looks pressed.

<img width="399" alt="Screenshot 2024-11-12 at 9 49 17 AM" src="https://github.com/user-attachments/assets/c923ebd9-bbcb-47cf-bd54-56ddbe865c31">

And here's the same example but WITH the `doClick`. More as I'd expect from the behavior.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20845#discussion_r1838535292


More information about the client-libs-dev mailing list