Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么可以';t我在IntelliJ插件的文本字段中键入';什么是弹出窗口?_Java_Swing_Popup_Intellij Plugin - Fatal编程技术网

Java 为什么可以';t我在IntelliJ插件的文本字段中键入';什么是弹出窗口?

Java 为什么可以';t我在IntelliJ插件的文本字段中键入';什么是弹出窗口?,java,swing,popup,intellij-plugin,Java,Swing,Popup,Intellij Plugin,我正在尝试制作一个简单的插件。我只想创建一个可以输入的弹出窗口。现在,弹出窗口出现了,但我无法集中精力或在文本字段中键入内容。下面是我如何创建弹出窗口的 public void actionPerformed(AnActionEvent e) { JTextField myTextField = new JTextField("Here I am", 20); JComponent myPanel = new JPanel(); myPanel.add(myTextFie

我正在尝试制作一个简单的插件。我只想创建一个可以输入的弹出窗口。现在,弹出窗口出现了,但我无法集中精力或在文本字段中键入内容。下面是我如何创建弹出窗口的

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);
}

要清楚的是,弹出窗口与它的JPanel和JTextField一起出现,但我无法集中精力或键入它。另外,myPanel.isEditable()返回true。

我不知道到底是什么问题,但我用这一行创建了弹出窗口,从而解决了这个问题

JBPopupFactory.getInstance().createComponentPopupBuilder(panel, textField).createPopup().showInBestPositionFor(e.getData(PlatformDataKeys.EDITOR));

这使弹出窗口居中。

通过调用组件PopubBuilder.setRequestFocus(true)我解决了这个问题。

您能解释一下您的意思吗?
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);
}