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..)
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!
For more exotic shapes: translucent and shaped windows. Works only in 6u10 and later.