Java JTextField Size fixTextFieldSize(JTextField field)

Here you can find the source of fixTextFieldSize(JTextField field)

Description

fix Text Field Size

License

LGPL

Declaration

public static JTextField fixTextFieldSize(JTextField field) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import javax.swing.*;

import java.awt.*;

public class Main {
    public static JTextField fixTextFieldSize(JTextField field) {
        final Dimension size = field.getPreferredSize();
        size.width = field.getMaximumSize().width;
        field.setMaximumSize(size);/*from   w w  w .  ja v a2 s  .  c om*/

        return field;
    }
}

Related

  1. adjustSize(JTextField textField)
  2. fixTextFieldsSize(JTextField... jTextFields)
  3. setMinimumSizeFromCols(JTextField component)