Here you can find the source of sameWidth(JComponent[] components, int width)
public static void sameWidth(JComponent[] components, int width)
//package com.java2s; import java.awt.Dimension; import java.util.List; import javax.swing.JComponent; public class Main { public static void sameWidth(JComponent[] components, int width) { for (int i = 0; i < components.length; i++) { Dimension size = components[i].getSize(); size.width = width;/*from w w w . java 2s.c om*/ components[i].setSize(size); } } 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); } } }