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

Krishna Addepalli krishna.addepalli at oracle.com
Wed Jul 26 07:28:42 UTC 2017

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/



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.





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/awt-dev/attachments/20170726/4b9ef497/attachment.html>

More information about the awt-dev mailing list