JButton文字与不同的字体家族在不同的词 [英] JButton text with different font family in different words
本文介绍了JButton文字与不同的字体家族在不同的词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
http://docs.oracle.com/javase/tutorial /uiswing/components/html.html
我已经试过了下面的代码,但是没有成功。
JButton button = new JButton(< html> Hello< font family = Serif> World< / font>< / html>);
可能是字体
标记属性 family
是错误的!
解决方案
可能是字体标签属性系列是错误的!
确实,正确的标签应该是:
< font face =Serif>< / font>
请看 HTML字体标签。所以在你的情况:
JButton button = new JButton(< html> Hello< font face = \Serif \ >世界< /字体>< / HTML> 中);
图片
I am trying to achieve a button with its text having two different font family.
I think, it can be achieved using HTML, as said on this page. http://docs.oracle.com/javase/tutorial/uiswing/components/html.html
I've tried the following code, but it's not working.
JButton button = new JButton("<html>Hello <font family=Serif>World</font></html>");
May be the font
tag attribute family
is wrong!
解决方案
May be the font tag attribute family is wrong!
It is indeed, the right tag should be:
<font face="Serif"></font>
Take a look to HTML font tag. So in your case:
JButton button = new JButton("<html>Hello <font face=\"Serif\">World</font></html>");
Picture
这篇关于JButton文字与不同的字体家族在不同的词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文