Here you can find the source of getMaxSize(JComponent[] components)
public static Dimension getMaxSize(JComponent[] components)
//package com.java2s; import java.awt.Dimension; import javax.swing.JComponent; public class Main { public static Dimension getMaxSize(JComponent[] components) { int width = 0; int height = 0; for (int i = 0; i < components.length; i++) { Dimension size = components[i].getPreferredSize(); width = Math.max(width, size.width); height = Math.max(height, size.height); }//from w ww. j a va2 s. c o m return new Dimension(width, height); } }