I can't seem to run a form on IntelliJ GUI builder
Exception in thread "main" java.awt.IllegalComponentStateException: contentPane cannot be set to null.
I assume the code to initialize the views are auto generated. Right now I only have a JPanel
and somehow it is not auto-initialized even thought it's clearly visible on the designer.
It's a Gradle project and I've chosen to run with the generated main function.
What do I have to do to get it working?
public class MyForm {
private JPanel jPanel;
public static void main(String[] args) {
JFrame frame = new JFrame("MyForm");
frame.setContentPane(new MyForm().jPanel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
IntelliJ IDEA is a pure Java Swing application. All the custom components like editor tabs are created manually, no third-party libraries are used for this. You can find all the details by looking at the IntelliJ IDEA Community Source code.
By default, the IntelliJ IDEA UI designer works by generating bytecode, which is unfortunately not supported with Gradle builds. You can change it to generate source code in Settings | Editor | GUI Designer.
see Intellij (Swing) GUI not compiling because of Gradle
solved by changing intellij settings (also see the screenshot)
i've checked:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With