void (@NotNull AnActionEvent e) { Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); e.getPresentation().setEnabled(owner instanceof JButton && owner.isEnabled()); }