• Post Reply Bookmark Topic Watch Topic
  • New Topic

Transparent JLabel

 
Santosh Kumar Raju
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Is it possible to have JLabel as a transparent item on JPanel?
The idea is to have JLabel as a water mark!!

Is it Possible?

regards,
Santosh.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JLabels, by default are transparent!

For water marks, you have two options.
1) Subclass JPane;, override paintComponent and draw the watermark string using g.drawString().
2) Check out the Swing FAQ. It has a code sample on using images as panel background.

Once, I had used a glass pane to display Demo Version on the top left corner of my application frame. That time I had used approach # 1 cited above.
 
Ryan Beckett
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use setOpaque() of javax.swing.JComponent class.
 
Santosh Kumar Raju
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Maneesh and Ryan !
Looks like i got what i needed . Thanks for your help.

Maneesh, i used your first approach and Ryan, i used your approach too.
Albeit in two seperate ways

regards,
Santosh.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!