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!
Buttons have their own font-family, so don't inherit from the cascade unless you tell it to.
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>");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With