Java tutorial
//package com.java2s; import java.awt.Component; import java.awt.Dimension; public class Main { /** * Sets the minimum size of the given components to the maximum size * of the given components. * @param components the components to size */ public static final void setMinimumSize(Component... components) { Dimension size = getMaximumSize(components); for (Component component : components) { component.setMinimumSize(size); } } /** * Returns the maximum preferred size of the given components. * @param components the components * @return Dimension */ public static final Dimension getMaximumSize(Component... components) { Dimension size = new Dimension(); for (Component component : components) { Dimension cSize = component.getPreferredSize(); if (size.width < cSize.width) { size.width = cSize.width; } if (size.height < cSize.height) { size.height = cSize.height; } } return size; } }