Here you can find the source of createDisabledTextComponent (String text, Color color, boolean textField)
private static JTextComponent createDisabledTextComponent (String text, Color color, boolean textField)
//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 createDisabledTextComponent(String text) { if (text.length() < DEFAULT_TEXT_COMPONENT_COLUMNS) return createDisabledTextComponent(text, null, true); else// ww w.j a v a2s . com 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; } }