• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Transparency

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic