Here you can find the source of sameSize(JComponent[] components)
public static Dimension sameSize(JComponent[] components)
//package com.java2s; import java.awt.Dimension; import java.util.List; import javax.swing.JComponent; public class Main { public static Dimension sameSize(List<JComponent> components) { JComponent[] array = new JComponent[components.size()]; array = components.toArray(array); return sameSize(array); }// www. j a v a2s . com public static Dimension sameSize(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); } Dimension result = new Dimension(width, height); for (int i = 0; i < components.length; i++) { components[i].setSize(result); } return result; } public static void setSize(Dimension size, JComponent[] components) { for (JComponent component : components) { component.setSize(size); } } public static void setSize(Dimension size, List<JComponent> components) { for (JComponent component : components) { component.setSize(size); } } }