<Swing Dev> [10][JDK-8075084] JOptionPane.showMessageDialog causes JScrollBar to move

Krishna Addepalli krishna.addepalli at oracle.com
Wed Dec 6 06:23:06 UTC 2017


Hi Sergey,

Per our conversation, I have tried to re-create the same behavior as posted in the previous mail: namely, trying to create a ModalEventFilter, and pass that to the EventDispatchThread, and then take over the events. 
But, the ModalEventFilter and its base class EventFilter are internal classes, which cannot be accessed outside the awt package.
Another point is, the function "createSecondaryLoop" has two signatures, one without parameters and one that takes the EventFilter parameter.
The one without parameters is what can be created at the application level and that does not install any overriding EventFilters, so the events continue to goto the old window as well.
Whereas in the case of the ModalEventFilter, the event will be consumed by the top-level Dialog, and the underlying dialog doesnot even get the event notification.

With this in mind, I think to recreate the problem with JFrame, I guess, we need to copy the functionality of Dialog.show() into JFrame.
Let me know your thoughts on this.

Thanks,
Krishna

-----Original Message-----
From: Krishna Addepalli 
Sent: Monday, November 20, 2017 5:10 PM
To: Sergey Bylokhov <sergey.bylokhov at oracle.com>; Semyon Sadetsky <semyon.sadetsky at oracle.com>; swing-dev at openjdk.java.net
Subject: RE: <Swing Dev> [10][JDK-8075084] JOptionPane.showMessageDialog causes JScrollBar to move

Hi Sergey,

I have analyzed it further, and found a possible root cause for the difference in the behavior.
It has to do with the way the "show()" function is written for JDialog/Dialog and a JFrame.
In the case of Dialog, there is the below code which takes control of the EventQueue in its show call:

                    modalityPushed();
                    try {
                        final EventQueue eventQueue = AccessController.doPrivileged(
                                (PrivilegedAction<EventQueue>) Toolkit.getDefaultToolkit()::getSystemEventQueue);
                        secondaryLoop = eventQueue.createSecondaryLoop(() -> true, modalFilter, 0);
                        if (!secondaryLoop.enter()) {
                            secondaryLoop = null;
                        }
                    } finally {
                        modalityPopped();
                    }
Here, when the "secondaryLoop.enter()", starts, it pumps all the events to the modal Dialog, rather than the underlying window (which could be another Dialog/Frame). 
For the case of JFrame, the check is only to see if it is blocked by another Dialog on top of it, but it does not stop the existing EventQueue, and start a secondaryLoop like in JDialog.

Hope this clarifies the difference in the behavioral difference between JDialog and JFrame in the testcase.

Thanks,
Krishna

-----Original Message-----
From: Sergey Bylokhov
Sent: Wednesday, November 15, 2017 4:18 AM
To: Krishna Addepalli <krishna.addepalli at oracle.com>; Semyon Sadetsky <semyon.sadetsky at oracle.com>; swing-dev at openjdk.java.net
Subject: Re: <Swing Dev> [10][JDK-8075084] JOptionPane.showMessageDialog causes JScrollBar to move

Hi, Krishna.
Last time in the discussion we had a question why it is not possible to reproduce the bug using JFrame and focus manipulation in the same way as "JOptionPane.showMessageDialog" works. Did you check why it works in one case and does not work in another?

On 12/11/2017 22:41, Krishna Addepalli wrote:
> Hi Semyon,
> 
> There has already been extensive analysis about this, in the original thread. I'll loop you in that conversation, so that you could suggest the way ahead.
> 
> Thanks,
> Krishna
> 
> -----Original Message-----
> From: Semyon Sadetsky
> Sent: Wednesday, November 8, 2017 11:25 PM
> To: Krishna Addepalli <krishna.addepalli at oracle.com>; 
> swing-dev at openjdk.java.net; Sergey Bylokhov 
> <sergey.bylokhov at oracle.com>
> Subject: Re: <Swing Dev> [10][JDK-8075084] 
> JOptionPane.showMessageDialog causes JScrollBar to move
> 
> This fix was already published on Swing alias:
> 
> http://mail.openjdk.java.net/pipermail/swing-dev/2016-October/006808.h
> tml
> 
> Please continue your discussions in the original thread.
> 
> --Semyon
> 
> 
> On 11/08/2017 06:51 AM, Krishna Addepalli wrote:
>> Any update on this Sergey?
>>
>> -----Original Message-----
>> From: Krishna Addepalli
>> Sent: Thursday, October 26, 2017 2:13 PM
>> To: swing-dev at openjdk.java.net; Sergey Bylokhov 
>> <sergey.bylokhov at oracle.com>
>> Subject: RE: <Swing Dev> [10][JDK-8075084] 
>> JOptionPane.showMessageDialog causes JScrollBar to move
>>
>> Hi Sergey,
>>
>> I have recreated the webrev for JDK-10 consolidated repo:
>>
>> http://cr.openjdk.java.net/~kaddepalli/8075084/webrev01/
>>
>> Please review and let me know your comments.
>>
>> Thanks,
>> Krishna
>>
>> -----Original Message-----
>> From: Jason Mehrens [mailto:jason_mehrens at hotmail.com]
>> Sent: Wednesday, August 30, 2017 7:54 PM
>> To: Krishna Addepalli <krishna.addepalli at oracle.com>; 
>> swing-dev at openjdk.java.net
>> Subject: Re: <Swing Dev> [10][JDK-8075084] 
>> JOptionPane.showMessageDialog causes JScrollBar to move
>>
>> Related bug: 
>> http://mail.openjdk.java.net/pipermail/swing-dev/2014-April/003394.ht
>> ml
>>
>> ________________________________________
>> From: swing-dev <swing-dev-bounces at openjdk.java.net> on behalf of 
>> Krishna Addepalli <krishna.addepalli at oracle.com>
>> Sent: Tuesday, August 29, 2017 3:17 AM
>> To: swing-dev at openjdk.java.net
>> Subject: Re: <Swing Dev> [10][JDK-8075084] 
>> JOptionPane.showMessageDialog causes JScrollBar to move
>>
>> Hi Sergey,
>>
>> Can we have the fix pushed in, as per our conversation?
>>
>> Thanks,
>> Krishna
>>
>> From: Krishna Addepalli
>> Sent: Wednesday, July 26, 2017 3:07 PM
>> To: swing-dev at openjdk.java.net
>> Cc: Prasanta Sadhukhan <prasanta.sadhukhan at oracle.com>; Sergey 
>> Bylokhov <sergey.bylokhov at oracle.com>
>> Subject: [10][JDK-8075084] JOptionPane.showMessageDialog causes 
>> JScrollBar to move
>>
>> Hi All,
>>
>> Please review the fix for bug:
>>
>> Bug: JDK- 8075084  https://bugs.openjdk.java.net/browse/JDK-8075084
>>
>> JDK 10 Webrev : 
>> http://cr.openjdk.java.net/~psadhukhan/8075084/webrev00/
>>
>> Summary:
>> This is an interesting test case written by Drew Jetter (http://webbugs.us.oracle.com/IMWeb/incidentReportView.do?incidentID=2688093). The test shows a vertical scroll bar, and whenever the user clicks on the arrow buttons, it pops up a message dialog. The moment user clicks on "OK" button, the movement of the scrollbar doesnot stop, and it keeps showing up the dialog box again and again, while also moving the scroll bar till it reaches the end.
>>
>> This issue has already been root-caused here : http://mail.openjdk.java.net/pipermail/swing-dev/2016-November/006938.html , just reiterating here again:
>>
>> The problem is that once a Modal dialog is shown on top of the scrollbar, it loses focus, and hence doesnot get the mouse release event (which is swallowed by the DialogBox). For the mouse press event, the scrollbar would have started a timer, which keeps firing and generating the move events, which is why the slider moves repeatedly.
>>
>> Proposed fix is, once the scroll bar has moved by unit distance, check if it is still in focus, and only then start the timer. Otherwise *do not* start the timer, and also set the button press to false.
>>
>> PS: This could be a design decision as well, since the use case is not that common for scrollbar to lose focus on mouse press, so I decided to check out the behavior in Qt 5.9.1, and found that it too behaves the same way. Of course it's not binding that Java should behave the same way as Qt, but it was interesting to know that Qt also had similar behavior.
>>
>> Thanks,
>> Krishna
>>
>>
> 


--
Best regards, Sergey.



More information about the swing-dev mailing list