Here you can find the source of createLabel(final String label, final int alignment, final Color background, final Color foreground)
Parameter | Description |
---|---|
label | the string to be displayed by the <code>JLabel</code> |
alignment | the horizontal alignment of the <code>JLabel</code> |
background | the background color to be used for the <code>JLabel</code> |
foreground | the foreground color to be used for the <code>JLabel</code> |
public static JLabel createLabel(final String label, final int alignment, final Color background, final Color foreground)
//package com.java2s; import java.awt.Color; import javax.swing.JLabel; public class Main { /**//w ww . j a va 2 s . co m * Creates a label with the given properties already preset. The label will also, by default, be opaque, so that the * background color specified will be able to show through. * * @param label the string to be displayed by the <code>JLabel</code> * @param alignment the horizontal alignment of the <code>JLabel</code> * @param background the background color to be used for the <code>JLabel</code> * @param foreground the foreground color to be used for the <code>JLabel</code> */ public static JLabel createLabel(final String label, final int alignment, final Color background, final Color foreground) { JLabel presetLabel = new JLabel(label, alignment); presetLabel.setForeground(foreground); presetLabel.setBackground(background); presetLabel.setOpaque(true); return presetLabel; } }