Run some code when a popup closes in my swing app
问题 In my app I display a popup using JPopupMenu . I want to run some code when this popup closes (either directly, programmatically or when escape key is pressed). For windows I can attach a WindowListener but JPopupMenu doesn't have any corresponding feature, and SwingUtilities.windowForComponent returns the root window of the app. How do I implement this? 回答1: How about adding a PopupMenuListener to it? Something like: jpopMenu.addPopupMenuListener(new PopupMenuListener { public void