void (@NotNull AnActionEvent e) { KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); e.getPresentation().setEnabled(focusManager.getFocusOwner() instanceof JComponent); }