AnAction (TreeExpander expander, JComponent component) { CollapseAllAction collapseAllToolbarAction = new CollapseAllAction(event -> expander); collapseAllToolbarAction.registerCustomShortcutSet(collapseAllToolbarAction.getShortcutSet(), component); return collapseAllToolbarAction; }