JBPopup () { DataContext dataContext = DataManager.getInstance().getDataContext(myLinkLabel); Ref<JComponent> lastSelected = new Ref<>(); DefaultActionGroup group = buildGroup(lastSelected); Runnable callback = () -> { ApplicationManager.getApplication().invokeLater(() -> { JComponent component = lastSelected.get(); if (component != null && !(component instanceof JPanel) && !(component instanceof JLabel)) { IdeFocusManager.getGlobalInstance().requestFocus(component, false); } }); }; String title = myMain != null ? IdeBundle.message("popup.title.add.group.options", myMain.getGroup()) : IdeBundle.message("popup.title.add.run.options"); ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(title, group, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true, callback, -1); popup.setHandleAutoSelectionBeforeShow(true); popup.addListSelectionListener(e -> { JBPopup jbPopup = PopupUtil.getPopupContainerFor((Component)e.getSource()); Object selectedItem = PlatformCoreDataKeys.SELECTED_ITEM.getData((DataProvider)e.getSource()); if (selectedItem instanceof AnActionHolder) { jbPopup.setAdText(getHint(((AnActionHolder)selectedItem).getAction()), SwingConstants.LEFT); } }); return popup; }