IntelliJ GUI form failed to init toolwindow, null pointer exception.
I have an IntelliJ GUI form which initializes a tool window. In the class bound to the form, I initialize JButtons at the top and in the constructor I add action listeners. My issue is, every time it tries to add the action listener it returns null pointer exception and in debugging the buttons have value of null. I've tried moving the adding of action listeners to the createUiComponents() method below but get the same error. Here is my code:
NifiToolWindow(ToolWindow toolWindow) {
logSearch.addActionListener(e -> toolWindow.hide(null));
}
And the button is initialized as:
private JButton logSearch;
The debugger says logSearch has value of null and I understand that its probably because its set to that in the first few lines of the class, however using the GUI form I dont see a way around this. I followed this example quite closely. https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/tool_window/src/myToolWindow
Any help would be great, thanks.
Please sign in to leave a comment.
Please post/link the full sources of your toolwindow/setup.
https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/tool_window/src/myToolWindow
Using this example exactly gives the error I'm talking about, I'm unsure how to find another way around it.
I found the solution, I had create custom box ticked in the gui designer, but an empty createGuiComponents() method. Therefore it was null.