-3

I'm trying to get the state of a window on Windows. I have to check if the window of word is active or inactive. I don't find any answer to this problem in Google. Does anyone knows how to do this or if this is possible at all?

Window activeWindow = javax.swing.FocusManager.getCurrentManager().getActiveWindow();

The code above returns always NULL.

Thank you for your answers.

Regards Roman

1 Answers1

1

Try to use frame.hasFocus() or frame.isFocusOwner()

https://docs.oracle.com/javase/7/docs/api/javax/swing/JFrame.html

artmmslv
  • 139
  • 3
  • 12
  • Isn't this just for Java application frames? I need to check if a window of an other programm is active like Word or PowerPoint. – roman tenger May 14 '18 at 12:11