static Dimension componentsBoundingSize(Container container, int insetBottomRight) { Rectangle r = new Rectangle(0, 0, 0, 0); for (Component c : container.getComponents()) r = rectangleUnion(r, c.getBounds()); ret new Dimension(r.x+r.width+insetBottomRight, r.y+r.height+insetBottomRight); }