tags:

views:

358

answers:

3

I am trying to program a small application but I would like the entire window to be glass with buttons and labels on top of it. Is it possible to do this within Java?

A: 

Hmm. I think that all Java GUI must be displayed, directly or indirectly, in a Window, and that's a heavyweight component. Not sure if you can make it transparent/translucent.

Try building a JFrame and setting its background color to new Color(255, 255, 255, 20) or so, where 20 is the alpha. That should either make it mostly transparent - or it won't work.

Carl Smotricz
+2  A: 

Assuming Java SWT and friends do not have built-in support for Windows Aero technology, you're going to have to call a native API via JNI. The native API you'll need to call is

DwmExtendFrameIntoClientArea(int windowHandle, MARGINS margins);

This native API is found in the DWMAPI.dll native library in Windows Vista and Windows 7, and is documented on MSDN.

There's lot of documentation on the web about how to call this function. For example, here's an article on doing this in C#. That should get you started.

Judah Himango
It should be noted that SWT has some internal APIs for calling DwmExtendFrameIntoClientArea. That might be a starting point for figuring this out.
Judah Himango
A: 

The point is that Windows does it for you. Ever used Windows Explorer? Yeah, it does that. That's the top bar. merely setting the opacity won't match the glass effect.

Alex