Frameshape on Desktop

Hi
I want to create a little Desktop-Game
and what I need is to know how
to give a Frame or JFrame, whatever,
a certain shape.
Normally a Frame has a rectangular shape
and with


Frame.setUndecorated() 

is achieved that only the frame itself is visible.
But what I need now is a frame that only shows an ellipse f.e. on the desktop.
If so, how is this possible?

Not possible with Java. You might be able to do this using JNI, but that is pretty advanced.

I’m sure I read somewhere on how to do this. Searching google didn’t help?

Thanks for the fast answer :slight_smile:
So I’ll have to put a little rectangular Frame around
the shapes I want to see on my desktop.
Java´s not so mighty at all :-\

@ zammbi
Maybe what you saw was also JNI like CaptainJester mentioned…

The only solution I found was
to make a screenshot from the desktop
and use parts of it to simulate something like transparency
so that you only see the parts you want from the frame.

EDIT:

http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/splashscreen/

does it help ?

You can do this with SWT, so if the feature is really important to you you could switch to that.

Alternatively you can embed AWT controls in SWT controls now, so you might be able to use that as well.

You can use JNA to do this, which is library for accessing native libraries from Java without need to use JNI. It has example that does exactly that for all three major platforms (win/mac/lin).

its also possible to fake transparency on a frame to achieve this effect. This is done using the Robot class to take a screenshot and place it as the background of the frame, the screenshot is refreshed at set intervals.

I think this chapter of Killer Game Programming in Java may have what you are looking for
https://fivedots.coe.psu.ac.th/~ad/jg/ch045/index.html

This should do the trick:

http://www.pushing-pixels.org/?p=260

Cheers,
Brett