Null is returned if none of the windows in this application has the focus
import java.awt.KeyboardFocusManager; import java.awt.Window; public class Main { public static void main() { Window windowFocusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow(); } }