I am trying to create a JWindow that sits on top of an external application.
I want the window to resize whenever the external application resizes (to match it) and be only on top of the external application and not everything else. (I can't use setAlwaysOnTop()
, because it would be always on top of everything).
By modifying code from the first answer from here I am able to find the external window title (for example Untitled - Notepad) and its handle if needed.
Using code from the first answer from here, I can get the dimensions of an external window from it's window title.
The problem with finding the dimensions from the code at the second link is that I have to always loop and check them (which is not optimal) and it isn't helpful in putting my window only on top of the external one.
Is there a way to implement what I want in Java? Ideally, I would (using JNA?) make a listener to the messages (WinEvents?) the OS sends to the external program to resize it, gain/lose focus etc and handle them somehow.