JComponent (AnActionEvent event) { InputEvent inputEvent = event.getInputEvent(); Object source; if (inputEvent != null && (source = inputEvent.getSource()) instanceof JComponent) { return (JComponent)source; } else { Component component = event.getData(PlatformCoreDataKeys.CONTEXT_COMPONENT); return component instanceof JComponent ? (JComponent)component : null; } }