Transparent Windows

I have seen some posts in the past that have asked if Java can do transparent windows with the answers indicating that it can’t be done. It looks like the ability has been added recently.

I have tried it on Windows 7 and it works.

Oracle may thinks it should adapt on current theme like aero glass, so they putted it.

That’s probably not the case. Window opacity normally applies to windows as a whole, so it’s not like you can change the alpha of individual pixels.

Actually, the API does support per-pixel translucency. Note also that if you’re using Java 7, there’s an “official” API now, and you shouldn’t use the AWTUtilities class.

Ha, Oracle’s own JWS doesn’t work, awesome.

I have an old project where I wanted to make your desktop into a physics sandbox. I wrote a 20 line C program which read the size of all open windows and streamed that to my Java program, which in turn created a JBox2D body of each window. Maximized windows and any window behind them were ignored. I then drew these using Java2D to a fully transparent fullscreen JFrame. It worked, but the performance of a 1920x1080 transparent JFrame was laughable, and I also had some problems when windows were moved around (kaboooooom said the physics), so I dropped it. It did “work” though.

Interesting. I wonder if changing the shape sends mouse events to the (native) window behind it or if it gets trapped in a rectangle surrounding it.

I did this a while back http://www.java-gaming.org/topics/transparent-jframe-background/24635/msg/208284/view.html

Though granted, in my window I don’t use the built in java components, but my own custom ones (using listeners, graphics and such)

(PS I also used an undecorated window so I added my own dragging, and it’s not totally smooth but good enough)

Clicks go through the window when the color is fully transparent, if that’s what you mean.

One problem IIRC is that you cannot get anti-aliased edges with window shapes, so it’s tough to get anything really fancy looking good as far as “shaping” a window, short of slightly rounded corners.

I had antialiasing on my physics desktop. Even transparency works…