简体   繁体   中英

Amharic display in Jtextarea

I want to be able to type Amharic on JTextArea or JTextField but the controls don't show the Amharic character but show boxes.

Let us say when a person types h on the keyboard I want to use certain map to translate h to our local language and display . The UTF-8 code for that letter is 1200 and I want the field to show our local script based on Unicode, but instead it shows boxes.

What could be wrong?

The font that you're using doesn't support that character. switch the JTextArea's font to "Nyala" and it should display your character correctly. I'm sure there are other fonts, but this is the one that MS Word uses.

Most common fonts don't have graphics for all of the unicode characters but if you type in a character into MS Word it will switch the font to one that supports that character.

You should install the font first or download https://keyman.com/desktop/ Amharic's keyboards or other Amharic's keyboard.

Open eclipse window > preferece > General > Appearance > Colors and Fonts preference page.

Select the font you want to change

Font font = new Font("Your new Amharic installed font and appear in the font list ", Font.PLAIN, 12);

public class Text {
    public static void main(String[] args) {

        ``// TODO Auto-generated method stub
        Font font = new Font("Abyssinica SIL", Font.PLAIN, 12);
        JTextArea txt = new JTextArea(20,10);
        JTextField txtField = new JTextField(10);``
        txtField.setFont(font);

         txt.setFont(font);

        JFrame frame = new JFrame(" አማረኛ  ሙክራ ");
        frame.setLayout(new FlowLayout(FlowLayout.LEFT));
        frame.setSize(400, 400);
        frame.add(txt);
        frame.add(txtField);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM