Dimension (Container container) { Dimension dimension = JBUI.emptySize(); for(int i = 0; i < container.getComponentCount(); i++){ Component component = container.getComponent(i); if (!component.isVisible()) continue; Dimension dimension1 = component.getMinimumSize(); dimension.width = Math.max(dimension.width, dimension1.width); if (i > 0){ dimension.height += vGap; } dimension.height += dimension1.height; } addInsets(dimension, container); return dimension; }