ListPopup disappears immediately when used after popup



I'm just starting out with JetBrains plugin development, so please forgive me if I'm doing something wrong here. Basically what I want to do is have a menu item that first pops up an input box, and then based on what the user enters in the input box, pops up a list of potential options. As a first start, I've created the following minimal modification to the file:

When run as-is, this works: it pops up a list of choices, and if you select one it prints out the selection to the console.

However, if you uncomment the "showMessageDialog" call, it then shows a message dialog, but then when it moves on to showing the selection menu, the menu appears for one instant, but then quickly disappears. This doesn't seem like expected behavior, but I'm not sure if I'm doing something wrong, or if this is a bug. Could someone provide guidance?

Thanks a lot!

Permanently deleted user

Hi! The problem here is in focus transfer after dialog closing: ListPopup appears and immediately lost focus that goes to main window (and it triggers popup closing). So showing popup after modal dialog is just bad pattern and misbehaving (on native level) is possible depending on OS, Java version etc.

Use single popup or popup-after-popup instead.


Thanks a lot for the quick reply!

I think the popup-after-popup pattern would probably solve my problem, but I'm not sure how to get a popup that does what I want to do. To demonstrate what I want to do a little bit more I modified the gist, still using a modal dialog:

Basically, what it does is it opens a dialog using "Messages.showInputDialog()", gets the input, and then uses the input in the "createListPopup()" call. I think what I need to do is create a Popup that allows the user to do text entry, but I'm not sure how to do so. Would you be able to give me any pointers towards an example of how to use a popup for text entry?

Thanks a lot in advance!


You can create a non-modal popup via com.intellij.openapi.ui.popup.JBPopupFactory#createComponentPopupBuilder


Thanks for the pointer! But I'm sorry, I'm still confused about how to get createComponentPopupBuilder to act similarly to a modal InputDialog. I've created a simple input panel "TextInputForm" with the IntelliJ GUI editor, and called it using the following code:

TextInputForm form = new TextInputForm();
JBPopupFactory jbPopupFactory = JBPopupFactory.getInstance();
ComponentPopupBuilder popupBuilder = jbPopupFactory.createComponentPopupBuilder(form.rootPanel, null);

This displays the form as a popup, but it's not possible to select the JTextField or JButton objects that I've added to the GUI. Are there any examples of using createComponentPopupBuilder for something like text entry? If so, it'd be great if I could see any reference code to work off of.

Permanently deleted user

Please try


Thanks a lot! setRequestFocus() and an actionlistener on the included components to call the next createPopupList call did the trick.


try use EventQueue.invokeLater to call you popup show


Please sign in to leave a comment.