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