JComponent (@NotNull DefaultActionGroup actions, @Nullable @NlsActions.ActionText String tooltip, @NotNull Icon icon) { DefaultActionGroup toolbarActionGroup = new DefaultActionGroup(); ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("PluginsHeaderToolbar", toolbarActionGroup, true); toolbar.setTargetComponent(toolbar.getComponent()); toolbar.setReservePlaceAutoPopupIcon(false); toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY); JComponent toolbarComponent = toolbar.getComponent(); toolbarActionGroup.add(new DumbAwareAction(tooltip, tooltip, icon) { @Override public void actionPerformed(@NotNull AnActionEvent e) { ListPopup actionGroupPopup = JBPopupFactory.getInstance(). createActionGroupPopup(null, actions, e.getDataContext(), true, null, Integer.MAX_VALUE); HelpTooltip.setMasterPopup(e.getInputEvent().getComponent(), actionGroupPopup); Component component = toolbarComponent.getComponent(0); Container dialogComponent = ((JComponent)component).getRootPane().getParent(); if (dialogComponent != null) { ComponentAdapter listener = new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { movePopup(); } @Override public void componentMoved(ComponentEvent e) { movePopup(); } private void movePopup() { if (actionGroupPopup.isVisible()) { actionGroupPopup.setLocation(new RelativePoint(component, getPopupPoint()).getScreenPoint()); actionGroupPopup.pack(true, true); } } }; dialogComponent.addComponentListener(listener); actionGroupPopup.addListener(new JBPopupListener() { @Override public void onClosed(@NotNull LightweightWindowEvent event) { dialogComponent.removeComponentListener(listener); } }); } actionGroupPopup.show(new RelativePoint(component, getPopupPoint())); } private Point getPopupPoint() { int dH = UIUtil.isUnderWin10LookAndFeel() ? JBUIScale.scale(1) : 0; return new Point(JBUIScale.scale(2), toolbarComponent.getComponent(0).getHeight() - dH); } }); toolbarComponent.setBorder(JBUI.Borders.empty()); return toolbarComponent; }