Index: trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java	(revision 5078)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java	(revision 5079)
@@ -369,18 +369,20 @@
     private static class ToolbarPopupMenu extends JPopupMenu {
         public ToolbarPopupMenu(final ActionDefinition action) {
-            
-            add(tr("Remove from toolbar",action.getDisplayName()))
-                    .addActionListener(new ActionListener() {
-                        public void actionPerformed(ActionEvent e) {
-                            Collection<String> t = new LinkedList<String>(getToolString());
-                            ActionParser parser = new ActionParser(null);
-                            // get text definition of current action
-                            String res = parser.saveAction(action);
-                            // remove the button from toolbar preferences
-                            t.remove( res );
-                            Main.pref.putCollection("toolbar", t);
-                            Main.toolbar.refreshToolbarControl();                
-                        }
-            });
+
+            if(action != null) {
+                add(tr("Remove from toolbar",action.getDisplayName()))
+                        .addActionListener(new ActionListener() {
+                            public void actionPerformed(ActionEvent e) {
+                                Collection<String> t = new LinkedList<String>(getToolString());
+                                ActionParser parser = new ActionParser(null);
+                                // get text definition of current action
+                                String res = parser.saveAction(action);
+                                // remove the button from toolbar preferences
+                                t.remove( res );
+                                Main.pref.putCollection("toolbar", t);
+                                Main.toolbar.refreshToolbarControl();
+                            }
+                });
+            }
             
             add(tr("Configure toolbar")).addActionListener(new ActionListener() {
@@ -801,4 +803,5 @@
     public ToolbarPreferences() {
         control.setFloatable(false);
+        control.addMouseListener(new PopupMenuLauncher(new ToolbarPopupMenu(null)));
     }
 
