JComponent (@NotNull AnAction action) { Presentation presentation = myPresentationFactory.getPresentation(action); JComponent customComponent = presentation.getClientProperty(CustomComponentAction.COMPONENT_KEY); if (customComponent == null) { presentation.putClientProperty(CustomComponentAction.MINIMAL_DEMENTION_SUPPLIER, myMinimumButtonSizeFunction); customComponent = createCustomComponent((CustomComponentAction)action, presentation); if (customComponent.getParent() != null && customComponent.getClientProperty(SUPPRESS_ACTION_COMPONENT_WARNING) == null) { customComponent.putClientProperty(SUPPRESS_ACTION_COMPONENT_WARNING, true); LOG.warn(action.getClass().getSimpleName() + ".component.getParent() != null in '" + myPlace + "' toolbar. " + "Custom components shall not be reused."); } presentation.putClientProperty(CustomComponentAction.COMPONENT_KEY, customComponent); customComponent.putClientProperty(CustomComponentAction.ACTION_KEY, action); ((CustomComponentAction)action).updateCustomComponent(customComponent, presentation); } AbstractButton clickable = UIUtil.findComponentOfType(customComponent, AbstractButton.class); if (clickable != null) { final class ToolbarClicksCollectorListener extends MouseAdapter { @Override public void mouseClicked(MouseEvent e) { ToolbarClicksCollector.record(action, myPlace, e, getDataContext()); } } if (!ContainerUtil.exists(clickable.getMouseListeners(), o -> o instanceof ToolbarClicksCollectorListener)) { clickable.addMouseListener(new ToolbarClicksCollectorListener()); } } return customComponent; }