我需要在我的应用程序中显示汉字。
我使用 Verdana 字体。
标签 (JLabel
) 使用字体正确显示这些字符,但文本按钮 (JButton
) 显示方 block 而不是字符。
有什么想法吗?
最佳答案
您可能需要以 unicode 形式输入中文字符,如下例所示:
JLabel chineseJLabel = new JLabel("\u6B22\u8FCE\u4F7F\u7528" + "\u0020\u0020Unicode\u0021");
chineseJLabel.setToolTipText("This is Traditional Chinese");
获取自 here 。然后您可以使用 Native2Ascii将字符串转换为 unicode。
关于Verdana 字体按钮中的 Java 汉字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8518000/