JComponent (@NotNull final JComponent dataComponent, @NotNull final Collection<Runnable> closeListeners, @Nullable final JComponent actionListenerComponent, final AnAction @NotNull ... customActions) { final PanelWithActions instance = new PanelWithActions(); // Box layout: panel goes to the left, console to the right final LayoutManager layout = new BoxLayout(instance, BoxLayout.LINE_AXIS); instance.setLayout(layout); // use actions from console itself final List<AnAction> actionList = new ArrayList<>(Arrays.asList(customActions)); final DefaultActionGroup toolbarActions = new DefaultActionGroup(); actionList.add(new MyCloseAction(closeListeners)); toolbarActions.addAll(actionList); final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.EDITOR_TOOLBAR, toolbarActions, false); toolbar.setTargetComponent(dataComponent); instance.add(toolbar.getComponent()); instance.add(dataComponent); if (actionListenerComponent != null) { AbstractConsoleRunnerWithHistory.registerActionShortcuts(actionList, actionListenerComponent); } return instance; }