Java Swing JLabel set color of text

www.‮tual‬turi.com
Java Swing JLabel set color of text
/**
 * @author L a u tturi.com
 * Java Swing Example: set color of text in JLabel
 */
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class Lautturi {
	public static void main(String[] args) {
		JFrame frame = new JFrame("Java Swing - lautturi");

		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(500, 300);
		frame.setLocationRelativeTo(null);
		
		JLabel title = new JLabel("set text color in jlabel", JLabel.CENTER);
		title.setForeground(Color.red);
		
		frame.add(title);
		frame.setVisible(true);
	}
}
Created Time:2017-10-08 21:14:16  Author:lautturi