Skip to main content

Translucent and shaped windows in core Java

Posted by kirillcool on February 27, 2008 at 9:38 AM PST

The lack of support for translucent and shaped windows has been a subject of quite a few complaints about AWT and Swing. This has finally been addressed in the latest 6u10 build.

Here is how a translucent window looks like:

window-translucent.png

And here is a shaped window:

window-shaped.png

And here is a translucent and shaped window:

window-translucent-shaped.png

For more (unofficial) information on where these APIs are located and how to use them, click through to Pushing Pixels.

Related Topics >>

Comments

That's really great news for Swing, and Java client in general. But then you have hacks like Dion Almaer over there spreading all that FUD about Swing and telling us that it's drowning. I think he should just stick to his Ajax agenda, maybe that will serve him better. But then again maybe that's what's his Ajax agenda is all about.

Are the shaped windows going to be anti-aliased with whatever is behind them? I've played with the jna libraries that allow you to do this with current Java, but the shaped window edges look pretty terrible if you're using any type of curves.

At last. Whohoo! :)

I do not want to rain on that parade but sjoyner is correct, if rounded shapes are to be used at all they need to be anti-aliased. But I don't know, maybe that is not possible?

It would also be good if there were some what to make the translucency of the painted stuff in the window actually decide the translucency of the window. That would of course also solve the anti-aliased edges...

Good stuff anyway.

It's really great to know about this. In GUI, Java was always far behind from Flash.Now its catching up.Thanks for posting this information.

Great work Kirill, your unwavering committment to posting so many of these snippets of useful and relevant information is most appreciated.

Finally. It's good news. Would be nice if the Swing team can add 'type ahead' feature to JFileChooser in the next update. The 'type ahead' feature for JFileChooser is a feature that Swing should have.

The translucent window looks great! Wouldn't it be more accurate to describe the shaped window as clipped? It appears to be a normal window clipped to an ellipse. I would expect a shaped window to adjust it's decorations to the border. Perhaps I misunderstood "shaped window"? Great work as usual Kirill, I really enjoy your blog.