I\'d like to know how I can code a Java program that knows which Windows application is in focus. I can have many windows open but I want to know the one that\'s being used
I'm afraid there's no java api for that. JVM does not know anything about the windows it does not manage. You'll probably have to use JNI and call this function
[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();
MSDN link
PS. THere is a GetWindowText function that you might want to use if you need to grab the title of the window.
This post has JNI examples that might be helpful for you.