Java JComponent Color createLabel(JComponent parent, String text, Color color)

Here you can find the source of createLabel(JComponent parent, String text, Color color)

Description

Creates and returns a label with the given text and color.

License

Open Source License

Declaration

public static JLabel createLabel(JComponent parent, String text, Color color) 

Method Source Code


//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;
    }
}

Related

  1. createColorChooser(Component component)
  2. createDisabledTextComponent (String text, Color color, boolean textField)
  3. createDisabledTextField (String text, Color color)
  4. createHorizontalLine(Color background)
  5. createLabel(final String label, final int alignment, final Color background, final Color foreground)
  6. createTextArea(String str, Color color)
  7. findPanel(JColorChooser chooser, String name)
  8. fixOsxColorChooser(JColorChooser chooser)
  9. flashMessage(final Window parent, String string, Color background, Color foreground, final long howLong)