Here you can find the source of fixTextFieldsSize(JTextField... jTextFields)
public static void fixTextFieldsSize(JTextField... jTextFields)
//package com.java2s; //License from project: LGPL import javax.swing.*; import java.awt.*; public class Main { public static void fixTextFieldsSize(JTextField... jTextFields) { for (JTextField field : jTextFields) { fixTextFieldSize(field);//from ww w.j a v a 2 s .c o m } } public static JTextField fixTextFieldSize(JTextField field) { final Dimension size = field.getPreferredSize(); size.width = field.getMaximumSize().width; field.setMaximumSize(size); return field; } }