Intellij idea 在IntelliJ GUI表单中添加操作侦听器时使用空指针
我正在使用IntelliJ GUI表单创建一个工具窗口,作为IntelliJ插件的一部分。这是绑定到表单的类中的一些代码:Intellij idea 在IntelliJ GUI表单中添加操作侦听器时使用空指针,intellij-idea,intellij-plugin,Intellij Idea,Intellij Plugin,我正在使用IntelliJ GUI表单创建一个工具窗口,作为IntelliJ插件的一部分。这是绑定到表单的类中的一些代码: private JButton checkNifi; NifiToolWindow(ToolWindow toolWindow) { checkNifi.addActionListener(e -> toolWindow.hide(null)); } 我知道当添加此操作侦听器时,按钮仍然为空,这就是问题所在,但是即使我执行checkNifi=new
private JButton checkNifi;
NifiToolWindow(ToolWindow toolWindow) {
checkNifi.addActionListener(e -> toolWindow.hide(null));
}
我知道当添加此操作侦听器时,按钮仍然为空,这就是问题所在,但是即使我执行checkNifi=new JButton(“某些文本”)代码>,则会在此行上抛出空指针
我应该补充一点,我还有一个ToolWindowFactory类,它如下所示:
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull com.intellij.openapi.wm.ToolWindow toolWindow) {
NifiToolWindow nifiToolWindow = new NifiToolWindow(toolWindow);
ContentFactory contentFactory = new ContentFactoryImpl();
Content content = contentFactory.createContent(nifiToolWindow.getContent(), "", false);
toolWindow.getContentManager().addContent(content);
}
这是从这里的例子
任何帮助或想法都会很好。我找到了解决方案,我在gui设计器中勾选了创建自定义框,但创建了一个空的createGuiComponents()方法。因此它是空的。我找到了解决方案,我在gui设计器中勾选了create custom box,但是一个空的createGuiComponents()方法。因此它是空的