Index: trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java	(revision 10171)
+++ trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java	(revision 10172)
@@ -43,4 +43,5 @@
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
 import javax.swing.JScrollPane;
 import javax.swing.Scrollable;
@@ -478,5 +479,20 @@
      */
     public static Window getWindowAncestorFor(EventObject e) {
-        return e != null && e.getSource() instanceof Component ? SwingUtilities.getWindowAncestor((Component) e.getSource()) : null;
+        if (e != null) {
+            Object source = e.getSource();
+            if (source instanceof Component) {
+                Window ancestor = SwingUtilities.getWindowAncestor((Component) source);
+                if (ancestor != null) {
+                    return ancestor;
+                } else {
+                    Container parent = ((Component) source).getParent();
+                    if (parent instanceof JPopupMenu) {
+                        Component invoker = ((JPopupMenu) parent).getInvoker();
+                        return SwingUtilities.getWindowAncestor(invoker);
+                    }
+                }
+            }
+        }
+        return null;
     }
 
