Mapping Unicode characters in Java

I tried to display some Unicode characters in the Sinhala range (80: 0D80-0DFF) in java swing components. These letters appear correctly in the eclipse console, but they appear as fields in JButtons, JTextArea, JTextPane, etc.

import java.awt.BorderLayout;
import javax.swing.*;

public class Unicode extends JFrame{

    public Unicode(){

        super("ක් කැ කැ කු අ ඉ");

        add(new JButton("ක් කැ කැ කු අ ඉ \u0D88"),BorderLayout.NORTH);
        add(new JTextField("ක් කැ කැ කු අ ඉ"), BorderLayout.CENTER);

        setSize(500,500);
        setVisible(true);
    }

    public static void main(String a[]){
        new Unicode();
    }
 }

      

I tried to display using symbols and character codes but doesn't work. A lot of the answers given by google don't work. Please help me. I am using Windows 7 with java 1.6.

Thank...

+3


source to share


2 answers


If eclipse can display sinhala fonts, then most likely you have a font file that has sinhala characters. Now the swing component is unable to select this font, so you need to explicitly specify which file to display.

To make a generalized solution, you need to iterate over the code pages and find which one supports the Sinhala unicode range.



Please see this link for more information:

http://content.hccfl.edu/pollock/Java/Fonts.htm

+1


source


Install the "IskolaPotha" font. I think it works correctly (I used this font). but the dose of Swing componententetns (no JFrame) does not display unicode "ක්යෝ" characters as expected.



+2


source







All Articles