Here you can find the source of createDisabledTextField (String text, Color color)
public static JTextComponent createDisabledTextField (String text, Color color)
//package com.java2s; import java.awt.*; import javax.swing.*; import javax.swing.text.*; public class Main { public static final int DEFAULT_TEXT_COMPONENT_COLUMNS = 40; public static final int DEFAULT_TEXT_COMPONENT_ROWS = 5; public static JTextComponent createDisabledTextField(String text) { return createDisabledTextComponent(text, null, true); }/*from w ww. j ava2 s .c om*/ public static JTextComponent createDisabledTextField(String text, Color color) { return createDisabledTextComponent(text, color, true); } public static JTextComponent createDisabledTextComponent(String text) { if (text.length() < DEFAULT_TEXT_COMPONENT_COLUMNS) return createDisabledTextComponent(text, null, true); else return createDisabledTextComponent(text, null, false); } private static JTextComponent createDisabledTextComponent(String text, Color color, boolean textField) { JTextComponent field; if (textField) { field = new JTextField(text); } else { field = new JTextArea(DEFAULT_TEXT_COMPONENT_ROWS, DEFAULT_TEXT_COMPONENT_COLUMNS); ((JTextArea) field).setLineWrap(true); ((JTextArea) field).setWrapStyleWord(true); field.setText(text); } field.setEnabled(false); if (color != null) field.setForeground(color); return field; } }