我正在尝试实现一个按钮,其文本具有两种不同的字体系列。
我认为,它可以使用 HTML 来实现,如本页所述。 http://docs.oracle.com/javase/tutorial/uiswing/components/html.html
我试过下面的代码,但它不工作。
JButton button = new JButton("<html>Hello <font family=Serif>World</font></html>");
可能是font
标签属性family
错误!
最佳答案
May be the font tag attribute family is wrong!
确实如此,正确的标签应该是:
<font face="Serif"></font>
查看HTML font tag .所以在你的情况下:
JButton button = new JButton("<html>Hello <font face=\"Serif\">World</font></html>");
图片
关于java - JButton 文本在不同的单词中具有不同的字体系列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21046164/