Component (@NotNull Component component) { final Component focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); if (focused == null) return null; if (focused == component || SwingUtilities.isDescendingFrom(focused, component)) return focused; return null; }