Index: trunk/src/org/openstreetmap/josm/Main.java
===================================================================
--- trunk/src/org/openstreetmap/josm/Main.java	(revision 2868)
+++ trunk/src/org/openstreetmap/josm/Main.java	(revision 2869)
@@ -111,9 +111,4 @@
     public static MapFrame map;
     /**
-     * The dialog that gets displayed during background task execution.
-     */
-    //public static PleaseWaitDialog pleaseWaitDlg;
-
-    /**
      * True, when in applet mode
      */
@@ -184,5 +179,4 @@
             map.mapView.removeLayer(layer);
             if (map.mapView.getAllLayers().isEmpty()) {
-                map.tearDownDialogsPane();
                 setMapFrame(null);
             }
Index: trunk/src/org/openstreetmap/josm/gui/MapFrame.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MapFrame.java	(revision 2868)
+++ trunk/src/org/openstreetmap/josm/gui/MapFrame.java	(revision 2869)
@@ -199,8 +199,11 @@
         // MapFrame gets destroyed when the last layer is removed, but the status line background
         // thread that collects the information doesn't get destroyed automatically.
-        if(statusLine.thread == null) return;
-        try {
-            statusLine.thread.interrupt();
-        } catch (Exception e) {}
+        if(statusLine.thread != null) {
+            try {
+                statusLine.thread.interrupt();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
     }
 
@@ -214,11 +217,4 @@
     public void initializeDialogsPane() {
         dialogsPanel.initialize(allDialogs);
-    }
-
-    /**
-     *
-     */
-    public void tearDownDialogsPane() {
-        dialogsPanel.tearDown();
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/MapStatus.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MapStatus.java	(revision 2868)
+++ trunk/src/org/openstreetmap/josm/gui/MapStatus.java	(revision 2869)
@@ -144,4 +144,5 @@
         public void run() {
             for (;;) {
+
                 MouseState ms = new MouseState();
                 synchronized (this) {
@@ -595,5 +596,5 @@
 
     @Override
-    public void addMouseListener(MouseListener ml) {
+    public synchronized void addMouseListener(MouseListener ml) {
         //super.addMouseListener(ml);
         lonText.addMouseListener(ml);
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java	(revision 2868)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java	(revision 2869)
@@ -142,9 +142,4 @@
         MapView.removeEditLayerChangeListener(inSelectionModel);
         DataSet.selListeners.remove(inSelectionModel);
-    }
-
-    @Override
-    public void tearDown() {
-        unregisterAsListener();
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java	(revision 2868)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java	(revision 2869)
@@ -119,11 +119,15 @@
 
         build();
+        refreshView();
+    }
+
+    @Override
+    public void showNotify() {
         DataSet.selListeners.add(this);
         MapView.addLayerChangeListener(this);
-        refreshView();
     }
 
     @Override
-    public void tearDown() {
+    public void hideNotify() {
         MapView.removeLayerChangeListener(this);
         DataSet.selListeners.remove(this);
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java	(revision 2868)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java	(revision 2869)
@@ -46,15 +46,4 @@
         this.add(mSpltPane);
         reconstruct(Action.ELEMENT_SHRINKS, null);
-    }
-
-    /**
-     * Invoke before the panel is discarded. This will in turn call {@see ToggleDialog#tearDown()}
-     * on every dialog.
-     *
-     */
-    public void tearDown() {
-        for(ToggleDialog dialog: allDialogs) {
-            dialog.tearDown();
-        }
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java	(revision 2868)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java	(revision 2869)
@@ -7,5 +7,4 @@
 import java.awt.BorderLayout;
 import java.awt.Component;
-import java.awt.GridLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -15,5 +14,4 @@
 import javax.swing.JCheckBox;
 import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
 import javax.swing.JScrollPane;
 import javax.swing.JTable;
@@ -47,16 +45,18 @@
     private SideButton upButton;
     private SideButton downButton;
-    private JPopupMenu popupMenu;
 
     public FilterDialog(){
         super(tr("Filter"), "filter", tr("Filter objects and hide/disable them."),
                 Shortcut.registerShortcut("subwindow:filter", tr("Toggle: {0}", tr("Filter")), KeyEvent.VK_F, Shortcut.GROUP_LAYER, Shortcut.SHIFT_DEFAULT), 162);
-
+        build();
+    }
+
+    @Override
+    public void showNotify() {
         MapView.addLayerChangeListener(this);
-        build();
     }
 
     @Override
-    public void tearDown() {
+    public void hideNotify() {
         MapView.removeLayerChangeListener(this);
     }
@@ -144,5 +144,4 @@
                     @Override
                     public String getToolTipText(MouseEvent e) {
-                        String tip = null;
                         java.awt.Point p = e.getPoint();
                         int index = columnModel.getColumnIndexAtX(p.x);
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java	(revision 2868)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java	(revision 2869)
@@ -47,8 +47,8 @@
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
+import org.openstreetmap.josm.tools.CheckParameterUtil;
 import org.openstreetmap.josm.tools.ImageProvider;
 import org.openstreetmap.josm.tools.Shortcut;
 import org.openstreetmap.josm.tools.ImageProvider.OverlayPosition;
-import org.openstreetmap.josm.tools.CheckParameterUtil;
 
 /**
@@ -70,4 +70,6 @@
      */
     static public void createInstance(MapFrame mapFrame) {
+        if (instance != null)
+            throw new IllegalStateException("Dialog was already created");
         instance = new LayerListDialog(mapFrame);
     }
@@ -115,5 +117,4 @@
         activateLayerAction = new ActivateLayerAction();
         adaptTo(activateLayerAction, selectionModel);
-        MapView.addLayerChangeListener(activateLayerAction);
         buttonPanel.add(new SideButton(activateLayerAction));
 
@@ -153,5 +154,4 @@
         selectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
         model = new LayerListModel(selectionModel);
-        MapView.addLayerChangeListener(model);
 
         // create the list control
@@ -185,5 +185,11 @@
 
     @Override
-    public void tearDown() {
+    public void showNotify() {
+        MapView.addLayerChangeListener(activateLayerAction);
+        MapView.addLayerChangeListener(model);
+    }
+
+    @Override
+    public void hideNotify() {
         MapView.removeLayerChangeListener(model);
         MapView.removeLayerChangeListener(activateLayerAction);
@@ -240,4 +246,10 @@
                 }
         );
+    }
+
+    @Override
+    public void destroy() {
+        super.destroy();
+        instance = null;
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java	(revision 2868)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java	(revision 2869)
@@ -159,10 +159,4 @@
         }
 
-        MapView.addEditLayerChangeListener(this);
-    }
-
-    @Override
-    public void tearDown() {
-        MapView.removeEditLayerChangeListener(this);
     }
 
@@ -170,4 +164,5 @@
     public void showNotify() {
         DataSet.selListeners.add(this);
+        MapView.addEditLayerChangeListener(this);
         updateSelection();
     }
@@ -176,4 +171,5 @@
     public void hideNotify() {
         DataSet.selListeners.remove(this);
+        MapView.removeEditLayerChangeListener(this);
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 2868)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 2869)
@@ -7,8 +7,8 @@
 import java.awt.Component;
 import java.awt.Dimension;
+import java.awt.FlowLayout;
 import java.awt.Graphics;
-import java.awt.FlowLayout;
+import java.awt.GridBagLayout;
 import java.awt.GridLayout;
-import java.awt.GridBagLayout;
 import java.awt.Image;
 import java.awt.Rectangle;
@@ -560,20 +560,8 @@
     }
 
-    /**
-     * This method is called by hosting panel before the panel with the toggle dialogs
-     * and the toggle dialogs themself are discared, for instance because no layer is
-     * left in JOSM and  the main screen turns from the map editor to the MOTD panel.
-     *
-     * Override in subclasses to unregister as listener. After tearDown() is invoked
-     * the dialog should be registered as listener.
-     *
-     * The default implementation is empty.
-     */
-    public void tearDown() {}
-
     protected JPanel getButtonPanel(int columns) {
         JPanel pnl = new JPanel();
         pnl.setLayout(Main.pref.getBoolean("dialog.align.left", false)
-        ? new FlowLayout(FlowLayout.LEFT) : new GridLayout(1,columns));
+                ? new FlowLayout(FlowLayout.LEFT) : new GridLayout(1,columns));
         return pnl;
     }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java	(revision 2868)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java	(revision 2869)
@@ -67,4 +67,8 @@
 
         build();
+    }
+
+    @Override
+    public void showNotify() {
         DataSet.selListeners.add(this);
         MapView.addLayerChangeListener(this);
@@ -72,5 +76,5 @@
 
     @Override
-    public void tearDown() {
+    public void hideNotify() {
         MapView.removeLayerChangeListener(this);
         DataSet.selListeners.remove(this);
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java	(revision 2868)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java	(revision 2869)
@@ -155,4 +155,5 @@
         listOfUsedTags.rebuildNecessary();
         DataSet.selListeners.add(this);
+        MapView.addEditLayerChangeListener(this);
         updateSelection();
     }
@@ -163,4 +164,5 @@
         DatasetEventManager.getInstance().removeDatasetListener(dataChangedAdapter);
         DataSet.selListeners.remove(this);
+        MapView.removeEditLayerChangeListener(this);
     }
 
@@ -587,11 +589,4 @@
         buttonPanel.add(this.btnDel);
         add(buttonPanel, BorderLayout.SOUTH);
-
-        MapView.addEditLayerChangeListener(this);
-    }
-
-    @Override
-    public void tearDown() {
-        MapView.removeEditLayerChangeListener(this);
     }
 
