On Tue, 22 Jul 2025 08:28:51 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> 
wrote:

>> Issue is seen that a popup doesn't get closed when the component that 
>> invokes it, gets removed from the parent container.
>> This is because the JPopupMenu does not listen to its invoker liefecycle 
>> thereby behaving as a standalone entity after creation.
>> Fix is made to make sure popup listens to its invoker lifecycle by 
>> registering its PropertyChangeListener to the invoker and listens to the 
>> ["ancestor" property name ], 
>> https://github.com/openjdk/jdk/blob/441dbde2c3c915ffd916e39a5b4a91df5620d7f3/src/java.desktop/share/classes/javax/swing/JComponent.java#L4853-L4858
>>  which will become null when removed, wherein we should dispose of the popup
>
> Prasanta Sadhukhan has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Test update

I'm able to run the test as is with the changes and the test passes locally and 
on CI. Some syntax requests but the test looks good so far.

src/java.desktop/share/classes/javax/swing/JPopupMenu.java line 1430:

> 1428:             indexCounter++;
> 1429:         }
> 1430:         if(indexCounter < maxCounter && values.elementAt(indexCounter).

Suggestion:

        if (indexCounter < maxCounter && values.elementAt(indexCounter).

test/jdk/javax/swing/JPopupMenu/TestPopupInvoker.java line 86:

> 84:             });
> 85:             if (isVisible) {
> 86:                 throw new RuntimeException("poup is visible after 
> component is removed");

Suggestion:

                throw new RuntimeException("popup is visible after component is 
removed");

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

Changes requested by dnguyen (Committer).

PR Review: https://git.openjdk.org/jdk/pull/26407#pullrequestreview-3049064507
PR Review Comment: https://git.openjdk.org/jdk/pull/26407#discussion_r2226690635
PR Review Comment: https://git.openjdk.org/jdk/pull/26407#discussion_r2226690156

Reply via email to