RFR: 6318027: BasicScrollBarUI does not disable timer when enclosing frame is disabled.

Alisen Chung achung at openjdk.org
Fri Aug 2 21:35:37 UTC 2024


On Thu, 1 Aug 2024 04:53:14 GMT, Abhishek Kumar <abhiscxk at openjdk.org> wrote:

>> Issue is
>> BasicScrollBarUI.ArrowButtonListener starts a timer in mousePressed(), and stops it in mouseReleased(). If the frame containing the scrollbar is disabled between the MOUSE_PRESSED and the MOUSE_RELEASED events, the mouseReleased() method is never called. If the frame is then re-enabled, the still-running timer causes it to scroll all the way to the end.
>> Fix is to check if [ArrowButtonListener.handledEvent](https://github.com/openjdk/jdk/blame/ee839b7f0ebe471d3877cddd2c87019ccb8ee5ae/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java#L1567) is still set when ActionEvent is processed then stop the timer and reset this variable.
>> 
>> CI testing is green and also SwingSet2 JScrollPane scrolling with this modification..
>
> src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java line 1614:
> 
>> 1612:             // mouseReleased is not called after mousePressed when
>> 1613:             // this AcionEvent is being processed
>> 1614:             if (buttonListener.handledEvent) {
> 
> Since the fix is added in BasicScrollBarUI, will it affect Aqua ScrollBar also?

I think most L&F's ScrollBarUI classes are extending BasicScrollBarUI so it might be worth checking if this issue also occurs in those L&Fs too

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20346#discussion_r1702335812


More information about the client-libs-dev mailing list