1

I have two Windows and I want to check if one of them is on front but do not have the focus. I have to write a test because we had that bug in our Software a few days ago. So the Window on top does not have the focus and I it is also not active.

UPD: I can not use Window.isFocusableWindow() or anything else related to the focus of a window!

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
Sigma
  • 37
  • 5
  • 1
    Possible duplicate of [How to detect if one swing window is above another one](https://stackoverflow.com/questions/17879308/how-to-detect-if-one-swing-window-is-above-another-one) – Arnaud Nov 24 '17 at 13:58
  • I already read that answer but I can not use any of the solution. I think my problem is more compilcated because regular it is not possible to have a window on top wihout the focus. – Sigma Nov 24 '17 at 14:07
  • Z-Ordering of windows is the OS's task so I think you're out of luck from within Java. The only way I'm aware (if you're using Windows) is a DLL created with VB, C#, C/C++ that uses [`GetTopWindow`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms633514(v=vs.85).aspx) and [`GetWindowText`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms633520(v=vs.85).aspx) and access it via [JNI](https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/jniTOC.html). – Gerold Broser Nov 25 '17 at 00:27
  • hm.. thank you so far. It is not mandatory that my test runs on a Windows machine so I think that is not an option. – Sigma Nov 27 '17 at 07:37

0 Answers0