1

This is a follow up to my previous question here, except this one explores JNA.

How would I go about using JNA to attach or place a JFrame ("even just a string of text would be fine") onto a running application window?

I have not used JNA before, I do not know where to start.

What i'm trying to accomplish is illustrated here:

enter image description here

If this can't be done with JNA or JNI, I will have to scrap my Java work and switch to C# (which I would prefer not to do, I am exploring all options).

Community
  • 1
  • 1
ThatGuy343
  • 2,354
  • 3
  • 30
  • 55
  • 1
    You still have yet to produce any code for this project of yours, we won't do it for you. – Elliott Frisch Jun 30 '14 at 04:19
  • Didn't this need to work under MacOs? – MadProgrammer Jun 30 '14 at 04:20
  • not asking for code mate, i'm asking for some guidance. I want to know this is possible and where to start..couldn't find any use from custom controllers – ThatGuy343 Jun 30 '14 at 04:21
  • I've googled this like crazy, no leads, have not found any place to start. I guess this isn't really done a lot. – ThatGuy343 Jun 30 '14 at 04:24
  • 1
    You'll have to figure out a way to get a list of native window ids... then a way to get a handle to them... then a way to get their size, position and call-backs for when they change. In short, you want a native windowing library and integration. – Elliott Frisch Jun 30 '14 at 04:28
  • Yikes, I think I'll just do this in another language...Thats more work than my application took so far. – ThatGuy343 Jun 30 '14 at 04:34
  • 1
    I will point out you will need those things regardless of the language you choose. – Elliott Frisch Jun 30 '14 at 04:52
  • Hey @ElliottFrisch what if the application I'm trying to accomplish this with is a java application? Does that change anything? – ThatGuy343 Jun 30 '14 at 05:16
  • Your question seems to **really** be *how do I draw on an arbitrary native window (in Java)*. **I don't know** how myself, if I had too I could probably figure out a way with SWT but it would probably be a hack. Does that help? – Elliott Frisch Jun 30 '14 at 05:21
  • Yes well i guess i'm out of luck, i'm not competent enough to do it with SWT as a hack. Although im now tempted to ask a question titled "how do I draw on an arbitrary native window (in Java)" as that perfectly describes what im asking. – ThatGuy343 Jun 30 '14 at 05:28
  • 1
    To draw into a native window, use Java to draw into a `BufferedImage` and then do a bit copy into the window (that'll be platform-specific, but JNA does have some examples of doing so). To have native code draw into a Java window, do the reverse (have the native code draw into an appropriate native buffer, then copy that buffer out into a `BufferedImage`, then use Java to copy the image to a `Window`. – technomage Jun 30 '14 at 12:07
  • If you just want to reparent the native representation of a Java window into a different native window, you'll need to figure out how to do that in native code first. JNA will give you the handle to the native window, but each platform has different window management strategies (and OSX no longer uses a hierarchy of windows in Java). – technomage Jun 30 '14 at 12:09
  • possible duplicate of [Unselectable overlay in java](http://stackoverflow.com/questions/28534009/unselectable-overlay-in-java). The linked question has an answer to this question. – Joe C Mar 01 '15 at 17:48
  • I dont think C# is any different then Java in this case, you need to find the right native window system methods and use them. – eckes Mar 01 '15 at 18:09

0 Answers0