Here you can find the source of createLabel(JComponent parent, String text, Color color)
public static JLabel createLabel(JComponent parent, String text, Color color)
//package com.java2s; //License from project: Open Source License import java.awt.*; import javax.swing.*; public class Main { /**//from ww w.ja v a2s . c o m * Creates and returns a label with the given text. */ public static JLabel createLabel(JComponent parent, String text) { return createLabel(parent, text, JLabel.LEADING); } /** * Creates and returns a label with a given style and text. */ public static JLabel createLabel(JComponent parent, String text, int style) { JLabel label = new JLabel(text, style); parent.add(label); return label; } /** * Creates and returns a label with the given text and color. */ public static JLabel createLabel(JComponent parent, String text, Color color) { JLabel label = createLabel(parent, text); label.setForeground(color); return label; } }