RFR: 4938801: The popup does not go when the component is removed. [v4]

Alexey Ivanov aivanov at openjdk.org
Thu Jul 24 19:19:56 UTC 2025


On Thu, 24 Jul 2025 18:51:41 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   typo
>
> src/java.desktop/share/classes/javax/swing/JPopupMenu.java line 961:
> 
>> 959:                                 popup.dispose();
>> 960:                                 popup = null;
>> 961:                             }
> 
> This doesn't work for me on Windows.
> 
> Well, the test passes because `jpm.isVisible()` returns `false` since `popup` is set to `null`:
> 
> https://github.com/openjdk/jdk/blob/4e53a9d9dfe7a1ac7c3d7402e5ca3a3d3fcbb709/src/java.desktop/share/classes/javax/swing/JPopupMenu.java#L881-L883
> 
> But the popup itself remains on the screen.

All you have to do is call `setVisible(false)` (possibly ensuring that `isVisible()` returns `true` first).

This will hide the popup menu and fire the relevant events which aren't sent now… and popup remains on the screen.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26407#discussion_r2229366856


More information about the client-libs-dev mailing list