Can I draw on the desktop?

Hi.

I’d like to be able to draw lines and images on top of other applications or on top of my shortcuts on the desktop.

I have investigated this for a while now, and I know it can be done with C++, and you could do something like that with .NET-languages (atleast to make the background invisible). But I still would like to do it in Java, if possible, as I know it the best.

So. Any ideas, is this possible? You can go into fullscreen mode with Java, but is it possible to show the usual desktop with other programs instead of the black fullscreen background (like invisible fullscreen :))?

No, you can’t in Java.

You can fake it by taking a screenshot and drawing on top of it, but that will catch all mouse events too, so the applications below it won’t respond to anything.

Actually I don’t need to interact with the other applications. That screenshot might be enough, if I had the program running in a small window or in the systray.

But after the screenshot, I think I’d need to maximize the window to be able to draw on top of it. And after a little while, I might have to minimize/restore it and pop it up again.

Or is there a way to take screenshots behind the Java application?

you’d have to take the screenshot before your window is visible.

check out Robot.screateScreenCapture

after you get the image, switch to fullscreen mode, draw your captured image, and then do whatever you want.

It will be flickering though, upon creating the window :-\

technically might be possible by using native code by creating a special type of canvas/frame, but not sure how easy it would be do implement, would have to be some sort of transparent overlay that allows clicks through and can draw at the same time.

I just tested the fullscreen trick. Well, it doesn’t work as it takes like almost 2 seconds to enter and exit the full screen mode.

But I guess I can try to do it with some other language then. Just wanted to confirm that there isn’t an easy way with Java :slight_smile:

Thanks anyway.

It always takes almost 2 seconds to enter full-screen mode. That’s why Java 6 includes the ability to add a splash screen.

True. I actually even tried that SplashScreen as I havent used it before, but it looks like you can’t draw on it (other than images) without pretty special magic tricks. And on top of that, you can’t change the position.