Dimension (Container target) { int maxWidth = 0; int maxHeight = 0; for (Component each : myComponents) { Dimension min = each.getMaximumSize(); maxWidth = Math.min(maxWidth, min.width); maxHeight = Math.min(maxHeight, min.height); } return new Dimension(maxWidth, maxHeight); }