void (JComponent toolbarComponent, JList<String> list, @NlsContexts.PopupTitle String title, JTextComponent textField, @NlsContexts.PopupAdvertisement String ad) { final Runnable callback = () -> { String selectedValue = list.getSelectedValue(); if (selectedValue != null) { textField.setText(selectedValue); IdeFocusManager.getGlobalInstance().requestFocus(textField, false); } }; final PopupChooserBuilder<String> builder = JBPopupFactory.getInstance().createListPopupBuilder(list); if (title != null) { builder.setTitle(title); } final JBPopup popup = builder .setMovable(false) .setResizable(false) .setRequestFocus(true) .setItemChosenCallback(callback) .createPopup(); if (ad != null) { popup.setAdText(ad, SwingConstants.LEFT); } JComponent parent = toolbarComponent != null ? toolbarComponent : textField; AlignedPopup.showUnderneathWithoutAlignment(popup, parent); }