On Mon, 14 Apr 2025 14:36:26 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

>> This test was designed to manually verify that clicking on the JComboBox 
>> when the frame containing it is about to close does not cause an 
>> IllegalStateException.
>> 
>> The test allowed the tester extra time to click on the JComboBox when 
>> closing the frame by adding a Thread.sleep() in the close button handler.
>> 
>> In this test, a JComboBox is displayed with a Close button at the bottom. 
>> The tester should click the Close button, then try to click the JComboBox 
>> arrow button to display the popup.
>> 
>> In the automated test, we save the JComboBox  location size before closing 
>> the frame. We then use this information to click on the JComboBox right 
>> before the frame is closed.
>
> test/jdk/javax/swing/JComboBox/ComboPopupBug.java line 80:
> 
>> 78:         }
>> 79:         catch (Exception e) {
>> 80:             throw new RuntimeException(e);
> 
> Swing is not thread-safe, you should get the location and size on EDT too.
> Suggestion:
> 
>         try {
>             SwingUtilities.invokeAndWait(() ->{
>                 comboBoxLocation = comboBox.getLocationOnScreen();
>                 comboBoxSize = comboBox.getSize();
>                 
>                 closeButton.doClick();
>             });
>         }
>         catch (Exception e) {
>             throw new RuntimeException(e);

By the way, since the `closeButton` is clicked on EDT, as it should, you can 
put both `comboBoxLocation` and `comboBoxSize` into `clickComboBox()` where 
they're used.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24624#discussion_r2042673896

Reply via email to