Here you can find the source of makeJTextField(Document d, String s, int len, Object listener)
public static JTextField makeJTextField(Document d, String s, int len, Object listener)
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.awt.Color; import java.awt.SystemColor; import java.awt.event.ActionListener; import javax.swing.JTextField; import javax.swing.event.DocumentListener; import javax.swing.text.Document; public class Main { public static final int DEFAULT_TEXTFIELD_WIDTH = 30; /**/* ww w . j ava 2 s. co m*/ * Factory Method to create TextFiled using specified params */ public static JTextField makeJTextField(Document d, String s, int len, Object listener) { JTextField pf = new JTextField(DEFAULT_TEXTFIELD_WIDTH) { public void setEnabled(boolean enabled) { super.setEnabled(enabled); //super.setEditable(enabled); super.setBackground(enabled ? Color.white : SystemColor.window); } }; pf.setEnabled(true); if (d != null) pf.setDocument(d); if (s != null) pf.setText(s); if (len != -1) pf.setColumns(len); pf.addActionListener((ActionListener) listener); //detect text changes pf.getDocument().addDocumentListener((DocumentListener) listener); return pf; } }