diff --git a/src/org/openstreetmap/josm/Main.java b/src/org/openstreetmap/josm/Main.java
index 2f47385..ba31820 100644
--- a/src/org/openstreetmap/josm/Main.java
+++ b/src/org/openstreetmap/josm/Main.java
@@ -21,6 +21,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import javax.swing.JComponent;
+import javax.swing.JFrame;
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.UIManager;
@@ -410,25 +411,30 @@ abstract public class Main {
     }
 
     static public void saveGuiGeometry() {
-	// if the gui.geometry preference is already set,
 	// save the current window geometry
-	String curGeometryPref = pref.get("gui.geometry");
-	if(curGeometryPref.length() != 0) {
-	    Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
-	    Rectangle bounds = parent.getBounds();
-	    int width = (int)bounds.getWidth();
-	    int height = (int)bounds.getHeight();
-	    int x = (int)bounds.getX();
-	    int y = (int)bounds.getY();
-	    if(width > screenDimension.width)
-		width = screenDimension.width;
-	    if(height > screenDimension.height)
-		width = screenDimension.height;
-	    if(x < 0)
-		x = 0;
-	    if(y < 0)
-		y = 0;
-	    pref.put("gui.geometry", width + "x" + height + "+" + x + "+" + y);
+	String newGeometry = "";
+	try {
+	    if(((JFrame)parent).getExtendedState() == JFrame.NORMAL) {
+		Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
+		Rectangle bounds = parent.getBounds();
+		int width = (int)bounds.getWidth();
+		int height = (int)bounds.getHeight();
+		int x = (int)bounds.getX();
+		int y = (int)bounds.getY();
+		if(width > screenDimension.width)
+		    width = screenDimension.width;
+		if(height > screenDimension.height)
+		    width = screenDimension.height;
+		if(x < 0)
+		    x = 0;
+		if(y < 0)
+		    y = 0;
+		newGeometry = width + "x" + height + "+" + x + "+" + y;
+	    }
 	}
+	catch (Exception e) {
+	    System.out.println("Failed to save GUI geometry: " + e);
+	}
+	pref.put("gui.geometry", newGeometry);
     }
 }
