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

Prasanta Sadhukhan psadhukhan at openjdk.org
Fri Jul 25 07:31:42 UTC 2025


> 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:

  Use setVisible(false) instead of dispose, update test

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/26407/files
  - new: https://git.openjdk.org/jdk/pull/26407/files/7091fb6e..c5da4598

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=26407&range=04
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=26407&range=03-04

  Stats: 38 lines in 2 files changed: 15 ins; 19 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/26407.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26407/head:pull/26407

PR: https://git.openjdk.org/jdk/pull/26407


More information about the client-libs-dev mailing list