如何改变 JLabel 中特定字符的颜色?例如,
JLabel lbl = new JLabel("My Text");
我希望 My
为蓝色,而 Text
为红色。
可能吗?
最佳答案
是的,检查How to Use HTML in Swing Components .
JLabel lbl = new JLabel("<html><font color=blue>My</font><font color=red>Text</font></html>");
关于java - 如何更改 JLabel 中特定字符的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9225602/