Index: src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java b/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
--- a/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java	(revision 18549)
+++ b/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java	(date 1662491666240)
@@ -384,6 +384,16 @@
         layerManager.removeActiveLayerChangeListener(activateLayerAction);
     }
 
+    @Override
+    protected int getPanelMaximumHeight() {
+        return this.layerList.getHeight() + this.layerList.getRowHeight();
+    }
+
+    @Override
+    protected int getPanelMinimumHeight() {
+        return Math.min(4 * this.layerList.getRowHeight(), getPanelMaximumHeight());
+    }
+
     /**
      * Returns the layer list model.
      * @return the layer list model
Index: src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java b/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
--- a/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(revision 18549)
+++ b/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java	(date 1662490208098)
@@ -909,6 +909,51 @@
         return new Dimension(dialogsPanel.getWidth(), preferredHeight);
     }
 
+    /**
+     * Return the maximum height for the dialog given the current contents
+     * @return The maximum height
+     * @since xxx
+     */
+    protected int getPanelMaximumHeight() {
+        return Integer.MIN_VALUE;
+    }
+
+    /**
+     * Return the minimum height for the dialog given the current contents
+     * @return The minimum height
+     * @since xxx
+     */
+    protected int getPanelMinimumHeight() {
+        return Integer.MIN_VALUE;
+    }
+
+    @Override
+    public Dimension getMaximumSize() {
+        if (!this.isCollapsed) {
+            int maxHeight = this.getPanelMaximumHeight();
+            if (maxHeight >= preferredHeight) {
+                // Use preferred, since maximum is not bounded for all intents and purposes.
+                Dimension buttons = this.buttonsPanel.getPreferredSize();
+                Dimension title = this.titleBar.getPreferredSize();
+                return new Dimension(this.dialogsPanel.getWidth(), title.height + maxHeight + buttons.height);
+            }
+        }
+        return super.getMaximumSize();
+    }
+
+    @Override
+    public Dimension getMinimumSize() {
+        if (!this.isCollapsed) {
+            int minimumHeight = this.getPanelMinimumHeight();
+            if (minimumHeight > 0) {
+                Dimension buttons = this.buttonsPanel.getMinimumSize();
+                Dimension title = this.titleBar.getMinimumSize();
+                return new Dimension(Math.max(buttons.width, title.width), title.height + minimumHeight + buttons.height);
+            }
+        }
+        return super.getMaximumSize();
+    }
+
     /**
      * Do something when the toggleButton is pressed.
      */
Index: src/org/openstreetmap/josm/gui/widgets/ScrollableTable.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/org/openstreetmap/josm/gui/widgets/ScrollableTable.java b/src/org/openstreetmap/josm/gui/widgets/ScrollableTable.java
--- a/src/org/openstreetmap/josm/gui/widgets/ScrollableTable.java	(revision 18549)
+++ b/src/org/openstreetmap/josm/gui/widgets/ScrollableTable.java	(date 1662491443380)
@@ -2,6 +2,7 @@
 package org.openstreetmap.josm.gui.widgets;
 
 import java.awt.Container;
+import java.awt.Dimension;
 import java.awt.Point;
 import java.awt.Rectangle;
 
@@ -43,4 +44,31 @@
             viewport.scrollRectToVisible(rect);
         }
     }
+
+    @Override
+    public Dimension getPreferredSize() {
+        if (super.isPreferredSizeSet()) {
+            return super.getPreferredSize();
+        }
+        Dimension pref = super.getPreferredSize();
+        return new Dimension(pref.width, this.getRowHeight() * this.getRowCount());
+    }
+
+    @Override
+    public Dimension getMaximumSize() {
+        if (isMaximumSizeSet()) {
+            return super.getMaximumSize();
+        }
+        Dimension max = super.getMaximumSize();
+        return new Dimension(max.width, this.getRowHeight() * (this.getRowCount() + 1));
+    }
+
+    @Override
+    public Dimension getMinimumSize() {
+        if (this.isMinimumSizeSet()) {
+            return super.getMinimumSize();
+        }
+        Dimension min = super.getMinimumSize();
+        return new Dimension(min.width, this.getRowHeight());
+    }
 }
