void () { Dimension preferredSize = new Dimension(); for (ColorDescriptionPanel panel : myDescriptionPanels) { Dimension size = panel.getPanel().getPreferredSize(); preferredSize.setSize(Math.max(size.getWidth(), preferredSize.getWidth()), Math.max(size.getHeight(), preferredSize.getHeight())); } setPreferredSize(preferredSize); }