JLabel set the background color

Reprinted from: http: //huangqiqing123.iteye.com/blog/1678208


Since Jlabel default are transparent, so the background color is set directly see the effect by setBackground (color), if you want to see the effect, you must first set the JLabel opaque on it.

 

 

Java code   Collection Code
  1. Tips = the JLabel  new new  the JLabel ( "being executed, please wait ..." );  
  2. tips.setOpaque ( to true ); // opaque JLabel component provided only to opaque, the background color setting valid  
  3. tips.setBackground(ColorUtil.LU_DOU_SHA);  
Published 34 original articles · won praise 9 · views 90000 +

Guess you like

Origin blog.csdn.net/tianyatest/article/details/47144291