Index: trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 4763)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 4765)
@@ -83,4 +83,8 @@
      */
     protected boolean isCollapsed;
+    /**
+     * Indicates whether dynamic button hiding is active or not.
+     */
+    protected boolean isButtonHiding;
 
     /** the preferred height if the toggle dialog is expanded */
@@ -89,4 +93,7 @@
     /** the label in the title bar which shows whether the toggle dialog is expanded or collapsed */
     private JLabel lblMinimized;
+
+    /** the label in the title bar which shows whether buttons are dynamic or not */
+    private JButton buttonsHide = null;
 
     /** the JDialog displaying the toggle dialog as undocked dialog */
@@ -132,14 +139,14 @@
         toggleAction.putValue("help", helpId.substring(0, helpId.length()-6));
 
-        /** show the minimize button */
-        lblMinimized = new JLabel(ImageProvider.get("misc", "normal"));
-        titleBar = new TitleBar(name, iconName);
-        add(titleBar, BorderLayout.NORTH);
-
-        setBorder(BorderFactory.createEtchedBorder());
-
         isShowing = Main.pref.getBoolean(preferencePrefix+".visible", defShow);
         isDocked = Main.pref.getBoolean(preferencePrefix+".docked", true);
         isCollapsed = Main.pref.getBoolean(preferencePrefix+".minimized", false);
+        isButtonHiding = Main.pref.getBoolean(preferencePrefix+".buttonhiding", true);
+
+        /** show the minimize button */
+        titleBar = new TitleBar(name, iconName);
+        add(titleBar, BorderLayout.NORTH);
+
+        setBorder(BorderFactory.createEtchedBorder());
 
         RedirectInputMap.redirectToMainContentPane(this);
@@ -222,7 +229,4 @@
             dialogsPanel.reconstruct(Action.COLLAPSED_TO_DEFAULT, this);
         } else if (!isDialogShowing()) {
-//            if (isButtonHidden()) {
-//                showButtonImpl();
-//            }
             showDialog();
             if (isDocked && isCollapsed) {
@@ -289,5 +293,4 @@
      */
     public void collapse() {
-        //        if (isShowing && isDocked && !isCollapsed) {
         if (isDialogInDefaultView()) {
             setContentVisible(false);
@@ -305,5 +308,4 @@
      */
     protected void expand() {
-        //        if (isShowing && isDocked && isCollapsed) {
         if (isDialogInCollapsedView()) {
             setContentVisible(true);
@@ -375,4 +377,5 @@
         public TitleBar(String toggleDialogName, String iconName) {
             setLayout(new GridBagLayout());
+
             lblMinimized = new JLabel(ImageProvider.get("misc", "normal"));
             add(lblMinimized);
@@ -404,5 +407,4 @@
                         @Override
                         public void mouseClicked(MouseEvent e) {
-                            // toggleExpandedState
                             if (isCollapsed) {
                                 expand();
@@ -415,4 +417,18 @@
                     }
             );
+
+            if(Main.pref.getBoolean("dialog.dynamic.buttons", true)) {
+                buttonsHide = new JButton(ImageProvider.get("misc", isButtonHiding ? "buttonhide" : "buttonshow"));
+                buttonsHide.setToolTipText(tr("Toggle dynamic buttons"));
+                buttonsHide.setBorder(BorderFactory.createEmptyBorder());
+                buttonsHide.addActionListener(
+                    new ActionListener(){
+                        public void actionPerformed(ActionEvent e) {
+                            setIsButtonHiding(!isButtonHiding);
+                        }
+                    }
+                );
+                add(buttonsHide);
+            }
 
             // show the sticky button
@@ -574,4 +590,11 @@
     }
 
+    protected void setIsButtonHiding(boolean val) {
+        isButtonHiding = val;
+        Main.pref.put(preferencePrefix+".buttonhiding", val);
+        buttonsHide.setIcon(ImageProvider.get("misc", val ? "buttonhide" : "buttonshow"));
+        stateChanged();
+    }
+
     public int getPreferredHeight() {
         return preferredHeight;
@@ -652,13 +675,4 @@
      */
     protected void stateChanged() {
-    }
-
-    /* use createLayout() instead of self-constructed dialogs */
-    @Deprecated
-    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));
-        return pnl;
     }
 
@@ -677,4 +691,6 @@
                 buttonsPanel.setVisible(false);
             }
+        } else if(buttonsHide != null) {
+            buttonsHide.setVisible(false);
         }
         return data;
@@ -683,5 +699,5 @@
     @Override
     public void eventDispatched(AWTEvent event) {
-        if(isShowing() && !isCollapsed) {
+        if(isShowing() && !isCollapsed && isButtonHiding) {
             Rectangle b = this.getBounds();
             b.setLocation(getLocationOnScreen());
