Determining Which Component or Window Has the Focus

// null is returned if none of the components in this application has the focus Component compFocusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); // null is returned if none of the windows in this application has the focus Window windowFocusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow(); // Use this method to determine whether a particular component has the focus boolean b = component.isFocusOwner();

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.