tags:

views:

229

answers:

2

Hi. I'm having a hard time trying to make a Java program with just a shape (e.g rectangle) as main window. I don't want the shape to be inside the 'OS-window' (with buttons to close and minimize etc..)

+3  A: 

I don't know if you can draw directly on the screen in Java (I tend to think you can't). But you could create a JDialog (which doesn't appear in the taskbar) and call setUndecorated(true) on it (to get rid of the title bar). Then you can do whatever custom painting you want with it.

Edit: kts points out that JWindow will work even better for this purpose. From the Javadocs:

It does not have the title bar, window-management buttons, or other trimmings associated with a JFrame, but it is still a "first-class citizen" of the user's desktop, and can exist anywhere on it.

And there's even a no-argument constructor, so you don't have to worry about passing in a null owner!

Michael Myers
That's what I was looking for, thanks :)
Johannes
you could just create a JWindow. It doesn't have that pesky JFrame/JDialog constructor. It doesn't show up in the task bar either. I don't hink it has decorations either. JDialog should work, but I always woory about passing null in as an argument.
KitsuneYMG
Good tip on JWindow. I didn't even realize that class existed, but it seems perfect for this job.
Michael Myers
Thanks for the JWindows :D It will work even better ;)
Johannes
+2  A: 

For more exotic shapes: translucent and shaped windows. Works only in 6u10 and later.

Sii