Java Swing How to - Show Japanese Characters in TItle Bar of JFrame








Question

We would like to know how to show Japanese Characters in TItle Bar of JFrame.

Answer

import javax.swing.JFrame;
import javax.swing.JLabel;
//w w w.j a v  a 2 s. c om
public class Main {
  public static void main(String[] argv) throws Exception {
    final String title = "Testing: \u30CD";

    JFrame frame = new JFrame(title);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    JLabel label = new JLabel(title);
    label.setSize(200, 100);
    frame.setContentPane(label);
    frame.pack();
    frame.setVisible(true);

  }
}