简体   繁体   English

Jtextarea中的阿姆哈拉语显示

[英]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. 我希望能够在JTextAreaJTextField上键入Amharic ,但是控件不会显示Amharic字符,而是显示框。

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 . 假设有人在键盘上输入h时,我想使用某些地图将h转换为我们的本地语言并显示 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. 该字母的UTF-8代码为1200,我希望该字段显示基于Unicode的本地脚本,但显示框。

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. 将JTextArea的字体切换为“ Nyala”,它将正确显示您的字符。 I'm sure there are other fonts, but this is the one that MS Word uses. 我确定还有其他字体,但这是MS Word使用的字体。

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. 大多数常见字体没有所有unicode字符的图形,但是如果您在MS Word中键入一个字符,它将把字体切换为支持该字符的字体。

You should install the font first or download https://keyman.com/desktop/ Amharic's keyboards or other Amharic's keyboard. 您应该先安装字体或下载https://keyman.com/desktop/ Amharic的键盘或其他Amharic的键盘。

Open eclipse window > preferece > General > Appearance > Colors and Fonts preference page. 打开“ Eclipse”窗口>“ preferece”>“常规”>“外观”>“颜色和字体”首选项页面。

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);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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