src/macosx/classes/sun/lwawt/LWChoicePeer.java

Print this page

        

@@ -169,11 +169,13 @@
         public void firePopupMenuWillBecomeVisible() {
             super.firePopupMenuWillBecomeVisible();
             SwingUtilities.invokeLater(() -> {
                 JPopupMenu popupMenu = getPopupMenu();
                 // Need to override the invoker for proper grab handling
-                if (popupMenu != null && popupMenu.getInvoker() != getTarget()) {
+                if (popupMenu != null
+                        && popupMenu.isShowing()
+                        && popupMenu.getInvoker() != getTarget()) {
                     // The popup is now visible with correct location
                     // Save it and restore after toggling visibility and changing invoker
                     Point loc = popupMenu.getLocationOnScreen();
                     SwingUtilities.convertPointFromScreen(loc, this);
                     popupMenu.setVisible(false);