• Post Reply Bookmark Topic Watch Topic
  • New Topic

Transparency

 
Michael Szul
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This was brought up under http://www.javaranch.com/ubb/Forum2/HTML/003335.html, and I would like to put in my quick request.
Does anybody know any way to set a color to transparent. Like if you make a JWindow with an animation on it and you want the background to be transparent. Is this possible with the Java API's.
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, and it's not hard. Color objects have opacity as part of their properties. It's referred to in the documentation as the alpha value.
Just create a Color object with an alpha value of 255, and the color of the object behind will show completely through.
Note it is *not* possible to do this with an AWT Frame or other top-level window objects. Frames are "heavyweight" components which include by definition an opaque background. You can change the alpha value on a top-level window, but it will have no effect.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
Michael Szul
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So with Java, you really couldn't make an application like say... Desk Flag (http://www.deskflag.com) or Virtual Girl.
You couldn't make an animation on a JWindow with the part of the frame that isn't being animated transparent, so that you could see the desktop.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!