Transparent Applications (JFrame)

Hi all,

Is there a way a JFrame can be made transparent to see the environment behind it outside the app it belongs too? For example, if I have a JPopupMenu or JFrame in which my Java app resides, how can I see my desktop through it for example.

Devyn

you can follow this thread, that talks about it.
http://www.java-gaming.org/cgi-bin/JGOForums/YaBB.cgi?board=Offtopic;action=display;num=1047842653;start=8

On Mac OS X:

ComponentPeer peer = component.getPeer();
if (peer instanceof apple.awt.CWindow) {
  CWindow cWindow = (CWindow)peer;
  float alpha = ((float) value) / 100;
  cWindow.setAlpha(alpha);
  component.setVisible(true); // Make the change take effect
}

[quote]On Mac OS X:

ComponentPeer peer = component.getPeer();
if (peer instanceof apple.awt.CWindow) {
  CWindow cWindow = (CWindow)peer;
  float alpha = ((float) value) / 100;
  cWindow.setAlpha(alpha);
  component.setVisible(true); // Make the change take effect
}

[/quote]
cool, thats something new.

However, if there isn’t a way of providing an image to be used for the alpha mask, its not particularly useful. :frowning:

Thnx for the replies. I could find several examples how I can do this in C++ which begs the question why SUN didn’t want to implement Frame transparency in Java. All high level languages support transparent Frames etc including some scripting languages such as Javascript (Transparent Menus) yet Java does not. I expected more… :-/

Devyn

P.S. Great TransDemo.java link pepe.

Hey is Pepe stealing my stuff :slight_smile: (just kidding)

I wrote up that TransDemo example when I wanted to emulate an irregular splash screen that a native windows app has that I am porting to Java. It did the trick well enough… but it isn’t a substitute for the real thing. I don’t even know that I will bother usingg it, as I want the splash screen to get drawn as fast as possible and loading the Robot class and grabbing the screen etc just delays that. Thanks to etromic for suggesting to use the Robot class though.

While a cool feature, this is really not something that will change our everyday life.
I’m sure that Cas will agree with me that Sun has better things to add than this. ;D
By the way, here is an interesting article about 1.5…
http://java.sun.com/features/2003/05/bloch_qa.html