Index: trunk/src/org/openstreetmap/josm/Main.java
===================================================================
--- trunk/src/org/openstreetmap/josm/Main.java	(revision 2183)
+++ trunk/src/org/openstreetmap/josm/Main.java	(revision 2185)
@@ -526,5 +526,5 @@
         // save the current window geometry and the width of the toggle dialog area
         String newGeometry = "";
-        String newToggleDlgWidth = "";
+        String newToggleDlgWidth = null;
         try {
             if (((JFrame)parent).getExtendedState() == JFrame.NORMAL) {
@@ -549,15 +549,20 @@
                 newGeometry = width + "x" + height + "+" + x + "+" + y;
             }
-
-            newToggleDlgWidth = Integer.toString(map.getToggleDlgWidth());
-            if (newToggleDlgWidth.equals(Integer.toString(map.DEF_TOGGLE_DLG_WIDTH))) {
-                newToggleDlgWidth = "";
+            
+            if (map  != null) {
+                newToggleDlgWidth = Integer.toString(map.getToggleDlgWidth());
+                if (newToggleDlgWidth.equals(Integer.toString(map.DEF_TOGGLE_DLG_WIDTH))) {
+                    newToggleDlgWidth = "";
+                }
             }
         }
         catch (Exception e) {
             System.out.println("Failed to save GUI geometry: " + e);
+            e.printStackTrace();
         }
         pref.put("gui.geometry", newGeometry);
-        pref.put("toggleDialogs.width", newToggleDlgWidth);
+        if (newToggleDlgWidth != null) {
+            pref.put("toggleDialogs.width", newToggleDlgWidth);
+        }
     }
 }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 2183)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 2185)
@@ -6,4 +6,5 @@
 import java.awt.Component;
 import java.awt.Dimension;
+import java.awt.Graphics;
 import java.awt.GridBagLayout;
 import java.awt.Image;
@@ -24,4 +25,5 @@
 import javax.swing.ImageIcon;
 import javax.swing.JButton;
+import javax.swing.JComponent;
 import javax.swing.JDialog;
 import javax.swing.JLabel;
@@ -415,5 +417,5 @@
      */
     private class TitleBar extends JPanel {
-        private JLabel leftPart;
+        final private JLabel lblTitle;
 
         public TitleBar(String toggleDialogName, String iconName) {
@@ -425,8 +427,23 @@
             ImageIcon inIcon = ImageProvider.get("dialogs", iconName);
             ImageIcon smallIcon = new ImageIcon(inIcon.getImage().getScaledInstance(16 , 16, Image.SCALE_SMOOTH));
-            leftPart = new JLabel("",smallIcon, JLabel.TRAILING);
-            leftPart.setIconTextGap(8);
-            add(leftPart, GBC.std());
-            add(Box.createHorizontalGlue(),GBC.std().fill(GBC.HORIZONTAL));
+            lblTitle = new JLabel("",smallIcon, JLabel.TRAILING);
+            lblTitle.setIconTextGap(8);
+            
+            JPanel conceal = new JPanel();
+            conceal.add(lblTitle);
+            conceal.setVisible(false);
+            add(conceal, GBC.std());
+            
+            // Cannot add the label directly since it would displace other elements on resize
+            JComponent lblTitle_weak = new JComponent() {
+                @Override
+                public void paintComponent(Graphics g) {
+                    lblTitle.paint(g);
+                }
+            };
+            lblTitle_weak.setPreferredSize(new Dimension(Integer.MAX_VALUE,20));
+            lblTitle_weak.setMinimumSize(new Dimension(0,20));
+            add(lblTitle_weak, GBC.std().fill(GBC.HORIZONTAL));
+
             addMouseListener(
                     new MouseAdapter() {
@@ -468,9 +485,9 @@
 
         public void setTitle(String title) {
-            leftPart.setText(title);
+            lblTitle.setText(title);
         }
 
         public String getTitle() {
-            return leftPart.getText();
+            return lblTitle.getText();
         }
     }
