I'm trying to make a simple plugin. I just want to create a popup that I can type in. Right now, the popup appears, but I can't focus on it or type in the textfield. Here is how I am creating the popup.
public void actionPerformed(AnActionEvent e) {
JTextField myTextField = new JTextField("Here I am", 20);
JComponent myPanel = new JPanel();
myPanel.add(myTextField);
JBPopupFactory.getInstance().createComponentPopupBuilder(myPanel, myTextField).createPopup().show(myPanel);
}
To be clear, the popup appears along with it's JPanel and JTextField, but I can't focus on it or type in it. Also, myPanel.isEditable() returns true.
I don't know what exactly the problem was, but I fixed it by creating the popup with this line instead.
JBPopupFactory.getInstance().createComponentPopupBuilder(panel, textField).createPopup().showInBestPositionFor(e.getData(PlatformDataKeys.EDITOR));
This centered the popup.