JComponent (@NotNull JCheckBox checkBox, @NotNull AnAction action, @NotNull String place) { // this component cannot be stored right in AnAction because of action system architecture: // one action can be shown on multiple toolbars simultaneously checkBox.setOpaque(false); checkBox.setBorder(JBUI.Borders.emptyRight(9)); checkBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JCheckBox checkBox = (JCheckBox)e.getSource(); DataContext dataContext = ActionToolbar.getDataContextFor(checkBox); InputEvent inputEvent = new KeyEvent(checkBox, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), 0, KeyEvent.VK_SPACE, ' '); AnActionEvent event = AnActionEvent.createFromAnAction(action, inputEvent, place, dataContext); ActionUtil.performActionDumbAwareWithCallbacks(action, event); } }); return checkBox; }