/** * Lays out the container. * * @param target The container which needs to be laid out. */ public void layoutContainer(Container target) { Insets insets; int x; int y; int count; int width; Component component; Dimension dimension; synchronized (target.getTreeLock()) { insets = target.getInsets(); x = insets.left; y = insets.top; count = target.getComponentCount(); width = 0; for (int i = 0; i < count; i++) { component = target.getComponent(i); if (component.isVisible()) { dimension = component.getPreferredSize(); width = Math.max(width, dimension.width); component.setSize(dimension.width, dimension.height); component.setLocation(x, y); y += dimension.height; } } // now set them all to the same width for (int i = 0; i < count; i++) { component = target.getComponent(i); if (component.isVisible()) { dimension = component.getSize(); dimension.width = width; component.setSize(dimension.width, dimension.height); } } } }
/** * Lays out the container. * * @param target The container which needs to be laid out. */ public void layoutContainer(Container target) { int count; Component component; Dimension dimension; synchronized (target.getTreeLock()) { count = target.getComponentCount(); for (int i = 0; i < count; i++) { component = target.getComponent(i); if (component.isVisible()) { dimension = component.getPreferredSize(); component.setSize(dimension.width, dimension.height); } } } }