Index: trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java	(revision 5801)
+++ trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java	(revision 5803)
@@ -6,6 +6,8 @@
 
 import java.awt.Component;
+import java.awt.MenuComponent;
 import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
+import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -79,4 +81,5 @@
     private JMenuItem offsetMenuItem = singleOffset;
     private Map_Rectifier_WMSmenuAction rectaction = new Map_Rectifier_WMSmenuAction();
+    private boolean bottomItemAdded = false;
 
     public ImageryMenu() {
@@ -114,9 +117,9 @@
      */
     public void refreshImageryMenu() {
-        removeAll();
+        removeDynamicItems();
 
         // for each configured ImageryInfo, add a menu entry.
         for (final ImageryInfo u : ImageryLayerInfo.instance.getLayers()) {
-            add(new AddImageryLayerAction(u));
+            addDynamic(new AddImageryLayerAction(u));
         }
 
@@ -150,16 +153,16 @@
             }
             if (!inViewLayers.isEmpty()) {
-                addSeparator();
+                addDynamicSeparator();
                 for (ImageryInfo i : inViewLayers) {
-                    add(new AddImageryLayerAction(i));
-                }
-            }
-        }
-
-        addSeparator();
-        add(new JMenuItem(rectaction));
-
-        addSeparator();
-        add(offsetMenuItem);
+                    addDynamic(new AddImageryLayerAction(i));
+                }
+            }
+        }
+
+        addDynamicSeparator();
+        addDynamic(rectaction);
+
+        addDynamicSeparator();
+        addDynamic(offsetMenuItem);
     }
 
@@ -217,3 +220,43 @@
         }
     }
+
+    /**
+     * Collection to store temporary menu items. They will be deleted 
+     * (and possibly recreated) when refreshImageryMenu() is called.
+     * @since 5803
+     */
+    private List <Object> dynamicItems = new ArrayList<Object>(20);
+    
+    /**
+     * Remove all the items in @field dynamicItems collection
+     * @since 5803
+     */
+    private void removeDynamicItems() {
+        for (Object item : dynamicItems) {
+            if (item instanceof JMenuItem) {
+                remove((JMenuItem)item);
+            }
+            if (item instanceof MenuComponent) {
+                remove((MenuComponent)item);
+            }
+            if (item instanceof Component) {
+                remove((Component)item);
+            }
+        }
+        dynamicItems.clear();
+    }
+
+    private void addDynamicSeparator() {
+        JPopupMenu.Separator s =  new JPopupMenu.Separator();
+        dynamicItems.add(s);
+        add(s);
+    }
+    
+    private void addDynamic(Action a) {
+        dynamicItems.add( this.add(a) );
+    }
+    
+    private void addDynamic(JMenuItem it) {
+        dynamicItems.add( this.add(it) );
+    }
 }
