Creating a multi-colored JLabel

A couple of ways to do this. The easiest being that you can use HTML in labels and hence add the font tag inside your text (see example). Another way is to create a custom extended JLabel component that exposes some methods to set the color of individual characters or ranges or characters and create a custom JLabel UI that takes this extra information to render the JLabel correctly.

import javax.swing.text.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.*;
import java.awt.*;
public class Main extends JFrame {
   public Main() {
      getContentPane().setLayout(new FlowLayout());
      JLabel label = new JLabel("<html><font color=blue>Colored</font> <font color=yellow>label</font></html>");
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent event) {
      setSize(300, 100);
   public static void main(String[] args) {
      (new Main()).show();