Using a Japanese font in Swing components

To answer this question, I installed a Japanese font to play around with. It’s called MS Mincho. After installing it, I modified the JDK properties so that it recognizes this font. I assume here that you are using JDK1.2.2. Go to c:\jdk1.2.2\jre\lib and copy to (make a backup of the original first). Then modify this file and change serif.plain.0 to MS Mincho,ANSI_CHARSET. Also add the entry filename.MS_Mincho=msmincho.ttf.

You can use this test program that allows you to display RTF text, using the RTFEditorKit. Point the URL in the application to

import javax.swing.text.html.*;
import javax.swing.text.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame
   public static void main(String []args) {
      Main main = new Main();;
   public Main() {
      JButton uriButton = new JButton("Go!");
      // needs to be final to allow the inner class to access it!
      final JTextField uriTextField = new JTextField();
      final JEditorPane htmlPane = new JEditorPane();
      uriButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent ae) {
            try {
               htmlPane.setPage(new URL(uriTextField.getText()));
            catch(Exception e) {
      getContentPane().setLayout(new BorderLayout());
      JPanel topPanel = new JPanel(new BorderLayout());
      topPanel.add(BorderLayout.CENTER, uriTextField);
      topPanel.add(BorderLayout.EAST, uriButton);
      getContentPane().add(BorderLayout.NORTH, topPanel);
      getContentPane().add(BorderLayout.CENTER, new JScrollPane(htmlPane));
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
      setSize(400, 400);

Feel free to post any more sample code or detailed explanation on how to change the file to add MS Mincho properly.