Java Equivalent to Get ForegroundWindow?

MSWindows native programming has a call named GetForegroundWindow(). This call returns the handle to an application window that currenlty is active (sometimes also termed as "has focus"). I'm looking for something equivalent in Java.

Note that any method that gets the name of the application (such as MSWord), and the file that is being processed (such as Document1.doc) will do.

It would also be nice to find a method of being notified by MSWindows when the foreground window changes.

And, finally, having this workable in both Linux and MSWindows would be great - even if the methods are different for the two operating systems.

[657 byte] By [LouArnolda] at [2007-11-27 5:54:46]
# 1

> Note that any method that gets the name of the

> application (such as MSWord), and the file that is

> being processed (such as Document1.doc) will do.

Did you notice the word "native" you used earlier? Java wouldn't know about other processes and their windows, and most certainly not in a system-independant way.

CeciNEstPasUnProgrammeura at 2007-7-12 15:49:35 > top of Java-index,Java Essentials,New To Java...
# 2
You can know when your java window loses/gains focus, but you can't find out about non-java windows. If you really need to get that info, you should look into JNI.Edit: Or switch to C++ ;p
hunter9000a at 2007-7-12 15:49:35 > top of Java-index,Java Essentials,New To Java...