Here you can find the source of fixButtonWidth(JButton... buttons)
public static void fixButtonWidth(JButton... buttons)
//package com.java2s; import java.awt.Dimension; import javax.swing.JButton; public class Main { public static void fixButtonWidth(JButton... buttons) { fixButtonWidth(0, buttons);//www. j av a2s. c o m } public static void fixButtonWidth(int padding, JButton... buttons) { Dimension d = new Dimension(); for (JButton b : buttons) { Dimension size = b.getPreferredSize(); d.width = Math.max(size.width, d.width); d.height = Math.max(size.height, d.height); } d.width += 2 * padding; for (JButton b : buttons) { b.setPreferredSize(d); } } }