Java JTextArea字体 [英] Java JTextArea font

查看:161
本文介绍了Java JTextArea字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的电脑上安装了一个名为BMW1的自定义字体。我试图循环这个字体中的所有条目,并将它们显示在JTextArea中。



我有以下代码:

  JTextArea displayArea = new JTextArea (); 
Font font = new Font(BMW1,Font.PLAIN,72);
displayArea.setFont(font);

String sample =; (int current = 0; current< 300; current ++)
sample + = new Character((char)current).toString()+\\\
;


displayArea.setText(sample);

当我运行我的程序时,它只是打印出那些小盒子(我认为这意味着它不能 t找到该迭代的字体条目)。

我在这里做错了什么? JTextArea是这种事情的最佳选择吗?如何做到这一点的任何建议?解决方案使用字体canDisplay()方法来确定Java不能显示这种字体。



最后,我改用了C#,它对自定义字体有更好的支持(至少在这种情况下)。

I have a custom font installed on my PC called "BMW1". I'm trying to loop through all entries in this font and display them in a JTextArea.

I have the following code:

JTextArea displayArea = new JTextArea();
Font font = new Font("BMW1", Font.PLAIN, 72);
displayArea.setFont(font);

String sample = "";
for (int current = 0; current < 300; current++)
    sample += new Character((char)current).toString() + "\n";

displayArea.setText(sample);

When I run my program, it just prints out those little boxes (which I assume means it couldn't find a font entry for that iteration).

Am I doing something wrong here? Is JTextArea the best option for this sort of thing? Any suggestions on how to do this?

解决方案

Used Font canDisplay() methods to determine that Java can't display this font.

I ended up switching to C# which has better support for custom fonts (at least in this particular case).

这篇关于Java JTextArea字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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