Java Swing How to - Display Unicode with Label








Question

We would like to know how to display Unicode with Label.

Answer

 //from ww  w. j  ava 2  s  . c om
import javax.swing.JLabel;
import javax.swing.JOptionPane;

public class Main {
  public static void main(String[] args) {
    JLabel label = new JLabel("\u0414\u043E\u0431\u0440"
        + "\u043E\u0020\u043F\u043E\u0436\u0430\u043B\u043E\u0432"
        + "\u0430\u0422\u044A\u0020\u0432\u0020Unicode\u0021");
    label.setToolTipText("This is Russian");

    
    JOptionPane.showMessageDialog(null, label);
    
  }
}