使用setFont(Font t)设置全部文字样式、大小

lab.setFont(new Font("宋体", 0, 25));
第一个参数代表字体
中间的0代表不加粗,改成1代表加粗
最后的代表文字大小

使用setForeground(Color c)设置全部文字颜色

label.setForeground(Color.red);

使用html语法换行、设置部分文字颜色:

"<html>this line<br><font color='red'>add a new line</font></html>"
其中<br>为换行。
效果如下:
Java的JLabel的换行,文字设置,指定文字颜色设置

相关文章:

  • 2022-12-23
  • 2022-01-06
  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-18
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
相关资源
相似解决方案