Index: trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java	(revision 11269)
+++ trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java	(revision 11270)
@@ -36,4 +36,6 @@
 import org.openstreetmap.josm.actions.ExpertToggleAction;
 import org.openstreetmap.josm.data.Bounds;
+import org.openstreetmap.josm.data.preferences.BooleanProperty;
+import org.openstreetmap.josm.data.preferences.IntegerProperty;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
@@ -47,4 +49,5 @@
 import org.openstreetmap.josm.tools.InputMapUtils;
 import org.openstreetmap.josm.tools.OsmUrlToBounds;
+import org.openstreetmap.josm.tools.Utils;
 import org.openstreetmap.josm.tools.WindowGeometry;
 
@@ -53,4 +56,12 @@
  */
 public class DownloadDialog extends JDialog {
+    private static IntegerProperty DOWNLOAD_TAB = new IntegerProperty("download.tab", 0);
+
+    private static BooleanProperty DOWNLOAD_AUTORUN = new BooleanProperty("download.autorun", false);
+    private static BooleanProperty DOWNLOAD_OSM = new BooleanProperty("download.osm", true);
+    private static BooleanProperty DOWNLOAD_GPS = new BooleanProperty("download.gps", false);
+    private static BooleanProperty DOWNLOAD_NOTES = new BooleanProperty("download.notes", false);
+    private static BooleanProperty DOWNLOAD_NEWLAYER = new BooleanProperty("download.newlayer", false);
+
     /** the unique instance of the download dialog */
     private static DownloadDialog instance;
@@ -131,8 +142,8 @@
 
         try {
-            tpDownloadAreaSelectors.setSelectedIndex(Main.pref.getInteger("download.tab", 0));
+            tpDownloadAreaSelectors.setSelectedIndex(DOWNLOAD_TAB.get());
         } catch (IndexOutOfBoundsException ex) {
             Main.trace(ex);
-            Main.pref.putInteger("download.tab", 0);
+            DOWNLOAD_TAB.put(0);
         }
 
@@ -148,5 +159,5 @@
                 tr("<html>Autostart ''Download from OSM'' dialog every time JOSM is started.<br>" +
                         "You can open it manually from File menu or toolbar.</html>"));
-        cbStartup.addActionListener(e -> Main.pref.put("download.autorun", cbStartup.isSelected()));
+        cbStartup.addActionListener(e -> DOWNLOAD_AUTORUN.put(cbStartup.isSelected()));
 
         pnl.add(cbNewLayer, GBC.std().anchor(GBC.WEST).insets(5, 5, 5, 5));
@@ -351,9 +362,9 @@
      */
     public void rememberSettings() {
-        Main.pref.put("download.tab", Integer.toString(tpDownloadAreaSelectors.getSelectedIndex()));
-        Main.pref.put("download.osm", cbDownloadOsmData.isSelected());
-        Main.pref.put("download.gps", cbDownloadGpxData.isSelected());
-        Main.pref.put("download.notes", cbDownloadNotes.isSelected());
-        Main.pref.put("download.newlayer", cbNewLayer.isSelected());
+        DOWNLOAD_TAB.put(tpDownloadAreaSelectors.getSelectedIndex());
+        DOWNLOAD_OSM.put(cbDownloadOsmData.isSelected());
+        DOWNLOAD_GPS.put(cbDownloadGpxData.isSelected());
+        DOWNLOAD_NOTES.put(cbDownloadNotes.isSelected());
+        DOWNLOAD_NEWLAYER.put(cbNewLayer.isSelected());
         if (currentBounds != null) {
             Main.pref.put("osm-download.bounds", currentBounds.encodeAsString(";"));
@@ -365,13 +376,10 @@
      */
     public void restoreSettings() {
-        cbDownloadOsmData.setSelected(Main.pref.getBoolean("download.osm", true));
-        cbDownloadGpxData.setSelected(Main.pref.getBoolean("download.gps", false));
-        cbDownloadNotes.setSelected(Main.pref.getBoolean("download.notes", false));
-        cbNewLayer.setSelected(Main.pref.getBoolean("download.newlayer", false));
+        cbDownloadOsmData.setSelected(DOWNLOAD_OSM.get());
+        cbDownloadGpxData.setSelected(DOWNLOAD_GPS.get());
+        cbDownloadNotes.setSelected(DOWNLOAD_NOTES.get());
+        cbNewLayer.setSelected(DOWNLOAD_NEWLAYER.get());
         cbStartup.setSelected(isAutorunEnabled());
-        int idx = Main.pref.getInteger("download.tab", 0);
-        if (idx < 0 || idx > tpDownloadAreaSelectors.getTabCount()) {
-            idx = 0;
-        }
+        int idx = Utils.clamp(DOWNLOAD_TAB.get(), 0, tpDownloadAreaSelectors.getTabCount() - 1);
         tpDownloadAreaSelectors.setSelectedIndex(idx);
 
@@ -414,5 +422,5 @@
      */
     public static boolean isAutorunEnabled() {
-        return Main.pref.getBoolean("download.autorun", false);
+        return DOWNLOAD_AUTORUN.get();
     }
 
