Java JLabel Create createJLabel(String text, Font font)

Here you can find the source of createJLabel(String text, Font font)

Description

Creates a label with a specific font.

License

Open Source License

Parameter

Parameter Description
text the text for the label.
font the font.

Return

The label.

Declaration

public static JLabel createJLabel(String text, Font font) 

Method Source Code

//package com.java2s;
/* ===========================================================
 * JFreeChart : a free chart library for the Java(tm) platform
 * ===========================================================
 *
 * (C) Copyright 2000-2017, by Object Refinery Limited and Contributors.
 *
 * Project Info:  http://www.jfree.org/jfreechart/index.html
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version./*from   ww  w.j a va  2 s .  com*/
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
 * USA.
 *
 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. 
 * Other names may be trademarks of their respective owners.]
 *
 */

import java.awt.Color;

import java.awt.Font;

import javax.swing.JLabel;

public class Main {
    /**
     * Creates a label with a specific font.
     *
     * @param text  the text for the label.
     * @param font  the font.
     *
     * @return The label.
     */
    public static JLabel createJLabel(String text, Font font) {
        JLabel result = new JLabel(text);
        result.setFont(font);
        return result;
    }

    /**
     * Creates a label with a specific font and color.
     *
     * @param text  the text for the label.
     * @param font  the font.
     * @param color  the color.
     *
     * @return The label.
     */
    public static JLabel createJLabel(String text, Font font, Color color) {
        JLabel result = new JLabel(text);
        result.setFont(font);
        result.setForeground(color);
        return result;
    }
}

Related

  1. createCenteredLabel(JLabel label)
  2. createFormPanel(JLabel label, JComponent component)
  3. createJLabel(Container c, String caption, int x, int y)
  4. createJLabel(final String text, final Font font, final Color color)
  5. createJLabel(String mlabel)
  6. createJLabel(String text, Font font)
  7. createLabel(String name, int x, int y, int width, int height, Font font)
  8. createLabel(String text, Font f)
  9. createLabel(String text, Font f, Color c, int position)