I'm writing a screensaver in Java. It's primarily for Windows, though I'd prefer it to be as portable as practical.
According to http://support.microsoft.com/kb/182383, when a screensaver is invoked with command line args /p HWND
, the screensaver should "Preview Screen Saver as child of window ." Presumably this is how screensavers should their little preview in the Screen Saver Settings dialog.
So how, in Java, do you create a JFrame or JComponent that's a child of a window that belongs to somebody else? I've looked at Embed HWND (Window Handle) in a JPanel which is sort of the reverse question: The developer controls the parent window and wants to embed a child window. In my case, I control a child component that I want into embed into a parent that is not "mine". Can I use JNA to do that?
I'd rather not have to maintain C code in addition to Java code. (So JNI is not preferred.) I understand that JDIC was supposed to meet this kind of need, but I've read that JDIC is essentially dead.
I'm running Windows 7, FWIW.
SetParent(this.Handle, PreviewWndHandle);
– LarsHSetParent()
is somehow "special", and is not possible in pure Java. – LarsH