boolean (@Nullable Component component) { if (component == null) return false; Window window = ComponentUtil.getWindow(component); if (window == null) return false; Component windowFocusOwner = window.getMostRecentFocusOwner(); return windowFocusOwner != null && SwingUtilities.isDescendingFrom(windowFocusOwner, component); }