Index: trunk/src/org/openstreetmap/josm/actions/UploadAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/UploadAction.java	(revision 2004)
+++ trunk/src/org/openstreetmap/josm/actions/UploadAction.java	(revision 2005)
@@ -31,5 +31,4 @@
 import org.openstreetmap.josm.gui.ExceptionDialogUtil;
 import org.openstreetmap.josm.gui.ExtendedDialog;
-import org.openstreetmap.josm.gui.OptionPaneUtil;
 import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
@@ -113,5 +112,5 @@
             return;
         if (Main.map == null) {
-            OptionPaneUtil.showMessageDialog(
+            JOptionPane.showMessageDialog(
                     Main.parent,
                     tr("Nothing to upload. Get some data first."),
@@ -124,5 +123,5 @@
         ConflictCollection conflicts = Main.map.mapView.getEditLayer().getConflicts();
         if (conflicts !=null && !conflicts.isEmpty()) {
-            OptionPaneUtil.showMessageDialog(
+            JOptionPane.showMessageDialog(
                     Main.parent,
                     tr("There are unresolved conflicts. You have to resolve these first."),
@@ -130,6 +129,5 @@
                     JOptionPane.WARNING_MESSAGE
             );
-            Main.map.conflictDialog.action.button.setSelected(true);
-            Main.map.conflictDialog.action.actionPerformed(null);
+            Main.map.conflictDialog.showDialog();
             return;
         }
@@ -152,5 +150,5 @@
 
         if (add.isEmpty() && update.isEmpty() && delete.isEmpty()) {
-            OptionPaneUtil.showMessageDialog(
+            JOptionPane.showMessageDialog(
                     Main.parent,
                     tr("No changes to upload."),
@@ -226,5 +224,5 @@
         );
         int optionsType = JOptionPane.YES_NO_CANCEL_OPTION;
-        int ret = OptionPaneUtil.showOptionDialog(
+        int ret = JOptionPane.showOptionDialog(
                 null,
                 msg,
@@ -232,4 +230,5 @@
                 optionsType,
                 JOptionPane.ERROR_MESSAGE,
+                null,
                 options,
                 defaultOption
@@ -265,5 +264,5 @@
         );
         int optionsType = JOptionPane.YES_NO_OPTION;
-        int ret = OptionPaneUtil.showOptionDialog(
+        int ret = JOptionPane.showOptionDialog(
                 null,
                 msg,
@@ -271,4 +270,5 @@
                 optionsType,
                 JOptionPane.ERROR_MESSAGE,
+                null,
                 options,
                 defaultOption
@@ -385,5 +385,5 @@
                         ex.getDisplayMessage()
                 );
-                OptionPaneUtil.showMessageDialog(
+                JOptionPane.showMessageDialog(
                         Main.map,
                         msg,
Index: trunk/src/org/openstreetmap/josm/gui/IconToggleButton.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/IconToggleButton.java	(revision 2004)
+++ trunk/src/org/openstreetmap/josm/gui/IconToggleButton.java	(revision 2005)
@@ -28,6 +28,7 @@
 
         Object o = action.getValue(Action.SHORT_DESCRIPTION);
-        if (o != null)
+        if (o != null) {
             setToolTipText(o.toString());
+        }
 
         action.addPropertyChangeListener(this);
@@ -44,4 +45,6 @@
             setSelected((Boolean)evt.getNewValue());
             requestFocusInWindow();
+        } else if (evt.getPropertyName().equals("selected")) {
+            setSelected((Boolean)evt.getNewValue());
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/MapFrame.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MapFrame.java	(revision 2004)
+++ trunk/src/org/openstreetmap/josm/gui/MapFrame.java	(revision 2005)
@@ -70,6 +70,6 @@
      * instead of adding directly to this list.
      */
-    public JPanel toggleDialogs = new JPanel();
-    public ArrayList<ToggleDialog> allDialogs = new ArrayList<ToggleDialog>();
+    private JPanel toggleDialogs = new JPanel();
+    private ArrayList<ToggleDialog> allDialogs = new ArrayList<ToggleDialog>();
 
     public final ButtonGroup toolGroup = new ButtonGroup();
@@ -135,5 +135,5 @@
     public void destroy() {
         for (ToggleDialog t : allDialogs) {
-            t.close();
+            t.closeDetachedDialog();
         }
         for (int i = 0; i < toolBarActions.getComponentCount(); ++i)
@@ -167,7 +167,8 @@
         for (Component c : toggleDialogs.getComponents()) {
             if (c instanceof ToggleDialog) {
-                boolean sel = Main.pref.getBoolean(((ToggleDialog)c).prefName+".visible");
-                ((ToggleDialog)c).action.button.setSelected(sel);
-                c.setVisible(sel);
+                ToggleDialog td = (ToggleDialog)c;
+                if (Main.pref.getBoolean(td.getPreferencePrefix()+".visible")) {
+                    td.showDialog();
+                }
             }
         }
@@ -179,7 +180,6 @@
      */
     public IconToggleButton addToggleDialog(ToggleDialog dlg) {
-        IconToggleButton button = new IconToggleButton(dlg.action);
-        dlg.action.button = button;
-        dlg.parent = toggleDialogs;
+        IconToggleButton button = new IconToggleButton(dlg.getToggleAction());
+        dlg.setParent(toggleDialogs);
         toolBarToggle.add(button);
         toggleDialogs.add(dlg);
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java	(revision 2004)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java	(revision 2005)
@@ -62,7 +62,7 @@
     private void buildList() {
         if(Main.main.undoRedo.commands.size() != 0) {
-            setTitle(tr("Command Stack: {0}", Main.main.undoRedo.commands.size()), true);
+            setTitle(tr("Command Stack: {0}", Main.main.undoRedo.commands.size()));
         } else {
-            setTitle(tr("Command Stack"), false);
+            setTitle(tr("Command Stack"));
         }
         if (Main.map == null || Main.map.mapView == null || Main.map.mapView.getEditLayer() == null)
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java	(revision 2004)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java	(revision 2005)
@@ -793,7 +793,7 @@
         if(propertyData.getRowCount() != 0 || membershipData.getRowCount() != 0) {
             setTitle(tr("Properties: {0} / Memberships: {1}",
-                    propertyData.getRowCount(), membershipData.getRowCount()), true);
+                    propertyData.getRowCount(), membershipData.getRowCount()));
         } else {
-            setTitle(tr("Properties / Memberships"), false);
+            setTitle(tr("Properties / Memberships"));
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java	(revision 2004)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java	(revision 2005)
@@ -142,7 +142,7 @@
         }
         if(getNumRelations() != 0) {
-            setTitle(tr("Relations: {0}", Main.main.getCurrentDataSet().relations.size()), true);
+            setTitle(tr("Relations: {0}", Main.main.getCurrentDataSet().relations.size()));
         } else {
-            setTitle(tr("Relations"), false);
+            setTitle(tr("Relations"));
         }
         selectRelation(selected);
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java	(revision 2004)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java	(revision 2005)
@@ -290,7 +290,7 @@
 
         if( (nodes+ways+relations) != 0) {
-            setTitle(tr("Sel.: Rel.:{0} / Ways:{1} / Nodes:{2}", relations, ways, nodes), true);
+            setTitle(tr("Sel.: Rel.:{0} / Ways:{1} / Nodes:{2}", relations, ways, nodes));
         } else {
-            setTitle(tr("Selection"), false);
+            setTitle(tr("Selection"));
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 2004)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 2005)
@@ -1,3 +1,2 @@
-// License: GPL. Copyright 2007 by Immanuel Scholz and others
 package org.openstreetmap.josm.gui.dialogs;
 
@@ -5,8 +4,8 @@
 
 import java.awt.BorderLayout;
+import java.awt.Component;
 import java.awt.Dimension;
 import java.awt.EventQueue;
 import java.awt.GridBagLayout;
-import java.awt.Component;
 import java.awt.Image;
 import java.awt.event.ActionEvent;
@@ -14,19 +13,19 @@
 import java.awt.event.ComponentAdapter;
 import java.awt.event.ComponentEvent;
+import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
-
-import javax.swing.AbstractButton;
+import java.util.logging.Logger;
+
+import javax.swing.AbstractAction;
 import javax.swing.BorderFactory;
 import javax.swing.Box;
+import javax.swing.ImageIcon;
 import javax.swing.JButton;
 import javax.swing.JDialog;
-import javax.swing.JFrame;
 import javax.swing.JLabel;
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
-import javax.swing.ImageIcon;
 
 import org.openstreetmap.josm.Main;
@@ -38,35 +37,89 @@
 
 /**
- * This class is a toggle dialog that can be turned on and off. It is attached
- * to a ButtonModel.
+ * This class is a toggle dialog that can be turned on and off.
+ * 
  *
- * @author imi
  */
 public class ToggleDialog extends JPanel implements Helpful {
-
+    private static final Logger logger = Logger.getLogger(ToggleDialog.class.getName());
+
+    /**
+     * The action to toggle the visibility state of this toggle dialog.
+     * 
+     * Emits {@see PropertyChangeEvent}s for the property <tt>selected</tt>:
+     * <ul>
+     *   <li>true, if the dialog is currently visible</li>
+     *   <li>false, if the dialog is currently invisible</li>
+     * </ul>
+     *
+     */
     public final class ToggleDialogAction extends JosmAction {
-        public final String prefname;
-        public AbstractButton button;
-
         private ToggleDialogAction(String name, String iconName, String tooltip, Shortcut shortcut, String prefname) {
             super(name, iconName, tooltip, shortcut, false);
-            this.prefname = prefname;
         }
 
         public void actionPerformed(ActionEvent e) {
-            if (e != null && !(e.getSource() instanceof AbstractButton)) {
-                button.setSelected(!button.isSelected());
+            toggleVisibility();
+        }
+
+        public void toggleVisibility() {
+            if (isShowing) {
+                hideDialog();
+            } else {
+                showDialog();
             }
-            Boolean selected = button.isSelected();
-            setVisible(selected);
-            Main.pref.put(prefname+".visible", selected);
-            if(!selected && winadapter != null) {
-                winadapter.windowClosing(null);
-            } else if (!Main.pref.getBoolean(action.prefname+".docked", true)) {
-                EventQueue.invokeLater(new Runnable(){
-                    public void run() {
-                        stickyActionListener.actionPerformed(null);
-                    }
-                });
+        }
+    }
+
+    /**
+     * The action to toggle this dialog.
+     */
+    private ToggleDialogAction toggleAction;
+    private String preferencePrefix;
+
+    private JPanel parent;
+    private  TitleBar titleBar;
+    private String title;
+
+    /** indicates whether the dialog is currently minimized or not */
+    private boolean collapsed;
+    /** indicates whether the dialog is docked or not */
+    private boolean docked;
+    /** indicates whether the dialog is showing or not */
+    private boolean isShowing;
+
+    /** the preferred height if the toggle dialog is expanded */
+    private int preferredHeight;
+    /** the label in the title bar which shows whether the toggle dialog is expanded or collapsed */
+    private JLabel lblMinimized;
+    /** the JDialog displaying the toggle dialog as undocked dialog */
+    private JDialog detachedDialog;
+
+
+    /**
+     * Constructor
+     * 
+     * @param name  the name of the dialog
+     * @param iconName the name of the icon to be displayed
+     * @param tooltip  the tool tip
+     * @param shortcut  the shortcut
+     * @param preferredHeight the preferred height for the dialog
+     */
+    public ToggleDialog(String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight) {
+        super(new BorderLayout());
+        this.preferencePrefix = iconName;
+        init(name, iconName, tooltip, shortcut, preferredHeight);
+    }
+
+    /**
+     * Sets the visibility of all components in this toggle dialog, except the title bar
+     * 
+     * @param visible true, if the components should be visible; false otherwise
+     */
+    protected void setContentVisible(boolean visible) {
+        Component comps[] = getComponents();
+        for(int i=0; i<comps.length; i++) {
+            if(comps[i] != titleBar) {
+                comps[i].setVisible(visible);
             }
         }
@@ -74,173 +127,41 @@
 
     /**
-     * The action to toggle this dialog.
-     */
-    public ToggleDialogAction action;
-    public final String prefName;
-
-    public JPanel parent;
-    WindowAdapter winadapter;
-    private ActionListener stickyActionListener;
-    private final JPanel titleBar = new JPanel(new GridBagLayout());
-    public JLabel label = new JLabel();
-
-    public ToggleDialog(final String name, String iconName, String tooltip, Shortcut shortcut, int preferredHeight) {
-        super(new BorderLayout());
-        this.prefName = iconName;
-        ToggleDialogInit(name, iconName, tooltip, shortcut, preferredHeight);
-    }
-
-    private void ToggleDialogInit(final String name, String iconName, String tooltip, Shortcut shortcut, final int preferredHeight) {
+     * Initializes the toggle dialog
+     * 
+     * @param name
+     * @param iconName
+     * @param tooltip
+     * @param shortcut
+     * @param preferredHeight
+     */
+    private void init(String name, String iconName, String tooltip, Shortcut shortcut, final int preferredHeight) {
         setPreferredSize(new Dimension(330,preferredHeight));
-        action = new ToggleDialogAction(name, "dialogs/"+iconName, tooltip, shortcut, iconName);
+        toggleAction = new ToggleDialogAction(name, "dialogs/"+iconName, tooltip, shortcut, iconName);
         String helpId = "Dialog/"+getClass().getName().substring(getClass().getName().lastIndexOf('.')+1);
-        action.putValue("help", helpId.substring(0, helpId.length()-6));
+        toggleAction.putValue("help", helpId.substring(0, helpId.length()-6));
+
         setLayout(new BorderLayout());
 
         // show the minimize button
-        final JLabel minimize = new JLabel(ImageProvider.get("misc", "normal"));
-        titleBar.add(minimize);
-
-        // scale down the dialog icon
-        ImageIcon inIcon = ImageProvider.get("dialogs", iconName);
-        ImageIcon smallIcon = new ImageIcon(inIcon.getImage().getScaledInstance(16 , 16, Image.SCALE_SMOOTH));
-        JLabel firstPart = new JLabel(name, smallIcon, JLabel.TRAILING);
-        firstPart.setIconTextGap(8);
-        titleBar.add(firstPart, GBC.std());
-        titleBar.add(Box.createHorizontalGlue(),GBC.std().fill(GBC.HORIZONTAL));
-
-        final ActionListener hideActionListener = new ActionListener(){
-            public void actionPerformed(ActionEvent e) {
-                boolean nowVisible = false;
-                Component comps[] = getComponents();
-                for(int i=0; i<comps.length; i++)
-                {
-                    if(comps[i] != titleBar)
-                    {
-                        if(comps[i].isVisible()) {
-                            comps[i].setVisible(false);
-                        } else {
-                            comps[i].setVisible(true);
-                            nowVisible = true;
-                        }
-                    }
-                }
-
-                Main.pref.put(action.prefname+".minimized", !nowVisible);
-                if(nowVisible == true) {
-                    setPreferredSize(new Dimension(330,preferredHeight));
-                    setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
-                    minimize.setIcon(ImageProvider.get("misc", "normal"));
-                } else {
-                    setPreferredSize(new Dimension(330,20));
-                    setMaximumSize(new Dimension(330,20));
-                    minimize.setIcon(ImageProvider.get("misc", "minimized"));
-                }
-                if(parent != null)
-                {
-                    // doLayout() - workaround
-                    parent.setVisible(false);
-                    parent.setVisible(true);
-                }
-            }
-        };
-        //hide.addActionListener(hideActionListener);
-
-        final MouseListener titleMouseListener = new MouseListener(){
-            public void mouseClicked(MouseEvent e) {
-                hideActionListener.actionPerformed(null);
-            }
-            public void mouseEntered(MouseEvent e) {}
-            public void mouseExited(MouseEvent e) {}
-            public void mousePressed(MouseEvent e) {}
-            public void mouseReleased(MouseEvent e) {}
-        };
-        titleBar.addMouseListener(titleMouseListener);
-
-        // show the sticky button
-        JButton sticky = new JButton(ImageProvider.get("misc", "sticky"));
-        sticky.setToolTipText(tr("Undock the panel"));
-        sticky.setBorder(BorderFactory.createEmptyBorder());
-        stickyActionListener = new ActionListener(){
-            public void actionPerformed(ActionEvent e) {
-                final JDialog f = new JDialog(JOptionPane.getFrameForComponent(Main.parent),false /* not modal*/);
-                if (parent != null) {
-                    parent.remove(ToggleDialog.this);
-                }
-                f.getContentPane().add(ToggleDialog.this);
-                f.addWindowListener((winadapter = new WindowAdapter(){
-                    @Override public void windowClosing(WindowEvent e) {
-                        f.getContentPane().removeAll();
-                        f.dispose();
-                        winadapter = null;
-
-                        // doLayout() - workaround
-                        setVisible(false);
-                        parent.add(ToggleDialog.this);
-                        if(Main.pref.getBoolean(action.prefname+".visible")) {
-                            setVisible(true);
-                        }
-                        titleBar.setVisible(true);
-                        if(e != null) {
-                            Main.pref.put(action.prefname+".docked", true);
-                        }
-                    }
-                }));
-                f.addComponentListener(new ComponentAdapter(){
-                    @Override public void componentMoved(ComponentEvent e) {
-                        Main.pref.put(action.prefname+".bounds", f.getX()+","+f.getY()+","+f.getWidth()+","+f.getHeight());
-                    }
-                });
-                String bounds = Main.pref.get(action.prefname+".bounds",null);
-                if (bounds != null) {
-                    String[] b = bounds.split(",");
-                    f.setBounds(Integer.parseInt(b[0]),Integer.parseInt(b[1]),Integer.parseInt(b[2]),Integer.parseInt(b[3]));
-                } else {
-                    f.pack();
-                }
-                Main.pref.put(action.prefname+".docked", false);
-                f.setVisible(true);
-                titleBar.setVisible(false);
-
-                if (parent != null) {
-                    // doLayout() - workaround
-                    parent.setVisible(false);
-                    parent.setVisible(true);
-                }
-            }
-        };
-        sticky.addActionListener(stickyActionListener);
-        titleBar.add(sticky);
-
-        // show the close button
-        JButton close = new JButton(ImageProvider.get("misc", "close"));
-        close.setToolTipText(tr("Close this panel. You can reopen it with the buttons in the left toolbar."));
-        close.setBorder(BorderFactory.createEmptyBorder());
-        final ActionListener closeActionListener = new ActionListener(){
-            public void actionPerformed(ActionEvent e) {
-                // fake an event to toggle dialog
-                action.actionPerformed(new ActionEvent(titleBar, 0, ""));
-            }
-        };
-        close.addActionListener(closeActionListener);
-        titleBar.add(close);
-
+        lblMinimized = new JLabel(ImageProvider.get("misc", "normal"));
+        titleBar = new TitleBar(name, iconName);
         add(titleBar, BorderLayout.NORTH);
-        titleBar.setToolTipText(tr("Click to minimize/maximize the panel content"));
 
         setVisible(false);
         setBorder(BorderFactory.createEtchedBorder());
 
-        if (!Main.pref.getBoolean(action.prefname+".docked", true)) {
+        docked = Main.pref.getBoolean(preferencePrefix+".docked", true);
+        if (!docked) {
             EventQueue.invokeLater(new Runnable(){
                 public void run() {
-                    stickyActionListener.actionPerformed(null);
+                    detach();
                 }
             });
         }
-        if (Main.pref.getBoolean(action.prefname+".minimized", false)) {
+        collapsed = Main.pref.getBoolean(preferencePrefix+".minimized", false);
+        if (collapsed) {
             EventQueue.invokeLater(new Runnable(){
                 public void run() {
-                    titleMouseListener.mouseClicked(null);
+                    collapse();
                 }
             });
@@ -248,16 +169,177 @@
     }
 
-    public void close()
-    {
-        if(winadapter != null) {
-            winadapter.windowClosing(null);
-        }
-    }
-
-    public void setTitle(String title, boolean active) {
-        if(active) {
-            label.setText("<html><b>" + title + "</b>");
+    /**
+     * Collapses the toggle dialog to the title bar only
+     * 
+     */
+    protected void collapse() {
+        setContentVisible(false);
+        this.collapsed = true;
+        Main.pref.put(preferencePrefix+".minimized", true);
+        setPreferredSize(new Dimension(330,20));
+        setMaximumSize(new Dimension(330,20));
+        lblMinimized.setIcon(ImageProvider.get("misc", "minimized"));
+        refreshToggleDialogsView();
+    }
+
+    /**
+     * Expands the toggle dialog
+     */
+    protected void expand() {
+        setContentVisible(true);
+        this.collapsed = false;
+        Main.pref.put(preferencePrefix+".minimized", false);
+        setPreferredSize(new Dimension(330,preferredHeight));
+        setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
+        lblMinimized.setIcon(ImageProvider.get("misc", "normal"));
+        refreshToggleDialogsView();
+    }
+
+    /**
+     * Replies the index of this toggle dialog in the view of
+     * toggle dialog.
+     * 
+     * @return
+     */
+    protected int getDialogPosition() {
+        for (int i=0; i< parent.getComponentCount(); i++) {
+            String name = parent.getComponent(i).getName();
+            if (name != null && name.equals(this.getName()))
+                return i;
+        }
+        return -1;
+    }
+
+    /**
+     * Displays the toggle dialog in the toggle dialog view on the right
+     * of the main map window.
+     * 
+     */
+    protected void dock() {
+        detachedDialog = null;
+
+        // check whether the toggle dialog view contains a placeholder
+        // for this toggle dialog. If so, replace it with this dialog.
+        //
+        int idx = getDialogPosition();
+        if (idx > -1) {
+            parent.remove(idx);
+            parent.add(ToggleDialog.this,idx);
         } else {
-            label.setText(title);
+            parent.add(ToggleDialog.this);
+        }
+
+        if(Main.pref.getBoolean(preferencePrefix+".visible")) {
+            setVisible(true);
+        } else {
+            setVisible(false);
+        }
+        titleBar.setVisible(true);
+        collapsed = Main.pref.getBoolean(preferencePrefix+".minimized", false);
+        if (collapsed) {
+            collapse();
+        } else {
+            expand();
+        }
+        docked = true;
+        Main.pref.put(preferencePrefix+".docked", docked);
+    }
+
+    /**
+     * Display the dialog in a detached window.
+     * 
+     */
+    protected void detach() {
+        setContentVisible(true);
+        setVisible(true);
+
+        // replace the toggle dialog by an invisible place holder. Makes sure
+        // we can place the toggle dialog where it was when it becomes docked
+        // again.
+        //
+        if (parent != null) {
+            int idx = getDialogPosition();
+            if (idx > -1) {
+                JPanel placeHolder = new JPanel();
+                placeHolder.setName(this.getName());
+                placeHolder.setVisible(false);
+                parent.add(placeHolder,idx);
+            }
+            parent.remove(ToggleDialog.this);
+        }
+
+        titleBar.setVisible(false);
+        detachedDialog = new DetachedDialog();
+        detachedDialog.setVisible(true);
+        refreshToggleDialogsView();
+        docked = false;
+        Main.pref.put(preferencePrefix+".docked", docked);
+    }
+
+    /**
+     * Hides the dialog
+     */
+    public void hideDialog() {
+        if (!isShowing) return;
+        if (detachedDialog != null) {
+            detachedDialog.setVisible(false);
+            detachedDialog.getContentPane().removeAll();
+            detachedDialog.dispose();
+        }
+        setVisible(false);
+        isShowing = false;
+        refreshToggleDialogsView();
+        toggleAction.putValue("selected", false);
+    }
+
+    /**
+     * Shows the dialog
+     */
+    public void showDialog() {
+        if (isShowing) return;
+        if (!docked) {
+            detach();
+        } else if (!collapsed) {
+            expand();
+            setVisible(true);
+            refreshToggleDialogsView();
+        } else {
+            setVisible(true);
+            refreshToggleDialogsView();
+        }
+        isShowing = true;
+        toggleAction.putValue("selected", true);
+    }
+
+    /**
+     * Toggles between collapsed and expanded state
+     * 
+     */
+    protected void toggleExpandedState() {
+        if (this.collapsed) {
+            expand();
+        } else {
+            collapse();
+        }
+    }
+
+    /**
+     * Refreshes the layout of the parent toggle dialog view
+     * 
+     */
+    protected void refreshToggleDialogsView() {
+        if(parent != null){
+            parent.validate();
+        }
+    }
+
+    /**
+     * Closes the the detached dialog if this toggle dialog is currently displayed
+     * in a detached dialog.
+     * 
+     */
+    public void closeDetachedDialog() {
+        if (detachedDialog != null) {
+            detachedDialog.setVisible(false);
         }
     }
@@ -268,3 +350,148 @@
         return "Dialog/"+help;
     }
+
+    /**
+     * Replies the action to toggle the visible state of this toggle dialog
+     * 
+     * @return the action to toggle the visible state of this toggle dialog
+     */
+    public AbstractAction getToggleAction() {
+        return toggleAction;
+    }
+
+    /**
+     * Replies the prefix for the preference settings of this dialog.
+     * 
+     * @return the prefix for the preference settings of this dialog.
+     */
+    public String getPreferencePrefix() {
+        return preferencePrefix;
+    }
+
+    /**
+     * Sets the parent displaying all toggle dialogs
+     * 
+     * @param parent the parent
+     */
+    public void setParent(JPanel parent) {
+        this.parent = parent;
+    }
+
+    /**
+     * Replies the name of this toggle dialog
+     */
+    @Override
+    public String getName() {
+        return "toggleDialog." + preferencePrefix;
+    }
+
+    /**
+     * Sets the title
+     * 
+     * @param title the title
+     */
+    public void setTitle(String title) {
+        titleBar.setTitle(title);
+    }
+
+    /**
+     * The title bar displayed in docked mode
+     * 
+     */
+    private class TitleBar extends JPanel {
+        private JLabel leftPart;
+
+        public TitleBar(String toggleDialogName, String iconName) {
+            setLayout(new GridBagLayout());
+            lblMinimized = new JLabel(ImageProvider.get("misc", "normal"));
+            add(lblMinimized);
+
+            // scale down the dialog icon
+            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));
+            addMouseListener(
+                    new MouseAdapter() {
+                        @Override
+                        public void mouseClicked(MouseEvent e) {
+                            toggleExpandedState();
+                        }
+                    }
+            );
+
+            // show the sticky button
+            JButton sticky = new JButton(ImageProvider.get("misc", "sticky"));
+            sticky.setToolTipText(tr("Undock the panel"));
+            sticky.setBorder(BorderFactory.createEmptyBorder());
+            sticky.addActionListener(
+                    new ActionListener(){
+                        public void actionPerformed(ActionEvent e) {
+                            detach();
+                        }
+                    }
+            );
+            add(sticky);
+
+            // show the close button
+            JButton close = new JButton(ImageProvider.get("misc", "close"));
+            close.setToolTipText(tr("Close this panel. You can reopen it with the buttons in the left toolbar."));
+            close.setBorder(BorderFactory.createEmptyBorder());
+            close.addActionListener(
+                    new ActionListener(){
+                        public void actionPerformed(ActionEvent e) {
+                            hideDialog();
+                        }
+                    }
+            );
+            add(close);
+            setToolTipText(tr("Click to minimize/maximize the panel content"));
+            setTitle(toggleDialogName);
+        }
+
+        public void setTitle(String title) {
+            leftPart.setText(title);
+        }
+
+        public String getTitle() {
+            return leftPart.getText();
+        }
+    }
+
+    /**
+     * The dialog class used to display toggle dialogs in a detached window.
+     * 
+     */
+    private class DetachedDialog extends JDialog {
+        public DetachedDialog() {
+            super(JOptionPane.getFrameForComponent(Main.parent),false /* not modal*/);
+            getContentPane().add(ToggleDialog.this);
+            addWindowListener(new WindowAdapter(){
+                @Override public void windowClosing(WindowEvent e) {
+                    getContentPane().removeAll();
+                    dispose();
+                    dock();
+                }
+            });
+            addComponentListener(new ComponentAdapter(){
+                @Override public void componentMoved(ComponentEvent e) {
+                    rememberGeometry();
+                }
+            });
+            String bounds = Main.pref.get(preferencePrefix+".bounds",null);
+            if (bounds != null) {
+                String[] b = bounds.split(",");
+                setBounds(Integer.parseInt(b[0]),Integer.parseInt(b[1]),Integer.parseInt(b[2]),Integer.parseInt(b[3]));
+            } else {
+                pack();
+            }
+            setTitle(titleBar.getTitle());
+        }
+
+        protected void rememberGeometry() {
+            Main.pref.put(preferencePrefix+".bounds", detachedDialog.getX()+","+detachedDialog.getY()+","+detachedDialog.getWidth()+","+detachedDialog.getHeight());
+        }
+    }
 }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java	(revision 2004)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java	(revision 2005)
@@ -121,7 +121,7 @@
 
         if(ucArr.length != 0) {
-            setTitle(tr("Authors: {0}", ucArr.length), true);
+            setTitle(tr("Authors: {0}", ucArr.length));
         } else {
-            setTitle(tr("Authors"), false);
+            setTitle(tr("Authors"));
         }
     }
