所以我想在 ACM 库对话框中用 Java 中的非英语语言的符号打印,但是当我运行它时,只出现小方块。
IODialog dialog = getDialog();
dialog.println("ზაზა");
所以我想在 ACM 库对话框中用 Java 中的非英语语言的符号打印,但是当我运行它时,只出现小方块。
IODialog dialog = getDialog();
dialog.println("ზაზა");
IODialog使用 JOptionPane 进行实现,因此它会遇到与 JOptionPane 相同的 unicode 处理问题。
这里有一种克服问题的方法。但是我们不喜欢链接,所以让我总结一下:
根据上面的评论,使用字体是您想要探索的。像这样创建一个新字体:
public class MyFont {
/*
Below code I extracted from
http://www.java-forums.org/java-tips/6522-swing-changing-component-default-font.html
then i customized it.
*/
public static void setUIFont (javax.swing.plaf.FontUIResource f){
java.util.Enumeration keys = UIManager.getDefaults().keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
Object value = UIManager.get (key);
if (value instanceof javax.swing.plaf.FontUIResource)
UIManager.put (key, f);
}
}
}
然后使用包含您的 unicode 字符的任何字体设置实际字体:
MyFont.setUIFont(new javax.swing.plaf.FontUIResource("Iskoola pota",Font.BOLD,18)); // setting the default font for application
所以它的作用是改变你的默认字体。您无需再做任何事情。如果您需要在进行更改之前更改回默认字体,那么您必须以这种方式重置默认字体。