JLabel设置背景色

转载自:http://huangqiqing123.iteye.com/blog/1678208


由于 Jlabel 默认是透明的,所以直接通过setBackground(color)设置背景色是看不到效果的,如果想看到效果,需要首先设置该JLabel不透明,就可以了。

 

 

Java代码   收藏代码
  1. JLabel tips = new JLabel("正在执行,请稍后...");  
  2. tips.setOpaque(true);//设置组件JLabel不透明,只有设置为不透明,设置背景色才有效  
  3. tips.setBackground(ColorUtil.LU_DOU_SHA);  
发布了34 篇原创文章 · 获赞 9 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/tianyatest/article/details/47144291