首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

JLable中怎么设置字体颜色

2011-12-28 
JLable中如何设置字体颜色?JLable jb new JLabel()jb.setText(我爱JAVA)要把jb当中的文字设置成红色

JLable中如何设置字体颜色?
JLable jb = new JLabel();
jb.setText("我爱JAVA");

要把jb当中的文字设置成红色怎么实现?

[解决办法]
setForeground 
public void setForeground(Color fg)设置此组件的前景色。

由外观来决定是否遵守此属性,某些外观可以选择忽略它。 

覆盖: 

类 Component 中的 setForeground 

参数: 

fg - 所需的前景 Color 

JLabel l1 = new JLabel("red"); 
l1.setForeground(Color.red);

热点排行
Bad Request.