JComponent () { JLabel label = new JLabel(AllIcons.General.GearPlain); label.setBorder(JBUI.Borders.empty(0, 4)); label.setHorizontalAlignment(SwingConstants.RIGHT); label.setVerticalAlignment(SwingConstants.CENTER); List<AnAction> sorters = createSorters(); new ClickListener() { @Override public boolean onClick(@NotNull MouseEvent event, int clickCount) { DefaultActionGroup group = new DefaultActionGroup(); if (!sorters.isEmpty()) { group.addAll(sorters); group.addSeparator(); } //addGroupers(group); //addFilters(group); group.add(new ToggleNarrowDownAction()); DataManager dataManager = DataManager.getInstance(); ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup( null, group, dataManager.getDataContext(label), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false); popup.addListener(new JBPopupListener() { @Override public void onClosed(@NotNull LightweightWindowEvent event) { myCanClose = true; } }); myCanClose = false; popup.showUnderneathOf(label); return true; } }.installOn(label); return label; }