Null is returned if none of the components in this application has the focus
import java.awt.Component; import java.awt.KeyboardFocusManager; public class Main { public static void main() { Component compFocusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager() .getFocusOwner(); } }