组件中的多语言 [英] multi language in Component

查看:272
本文介绍了组件中的多语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Swing,并且我需要组件能够同时显示多种语言(在一个组件中)。但是,英文字符以外的字符显示为正方形。



组件只是 JTextPane JEditorPane JTextField JTextArea 和所有默认的东西。 >

为了达到多语言支持的目标,我必须做些什么?

解决方案

使用完整的 Unicode字体。他们很大。然后 setFont(...)就行了。



如果你想打包一个字体, code> loadFont 和 registerFont 都可以。

  Font font = Font.createFont(Font.TRUETYPE_FONT,
getClass()。getResourceAsStream(/ ...));
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.registerFont(font);


I am using Swing, and I need the components to be able to display multiple languages at the same time (inside one component). However, the characters other than English characters are displayed as squares.

The Components are just JTextPane, JEditorPane, JTextField, JTextArea and all the default stuff.

What must I do to achieve the goal of multi language support?

解决方案

Use a full Unicode font. They are large. Then setFont(...) does the trick.

If you want to pack a font with your application loadFont and registerFont will do.

    Font font = Font.createFont(Font.TRUETYPE_FONT,
        getClass().getResourceAsStream("/..."));
    GraphicsEnvironment ge =
        GraphicsEnvironment.getLocalGraphicsEnvironment();
    ge.registerFont(font);

这篇关于组件中的多语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆