So I'm trying out IntelliJ IDEA's content designer for a simple GUI, and I followed all guides on using it, but it when run from IDEA (not compiled into a JAR yet) it comes back with the following error:
Exception in thread "main" java.awt.IllegalComponentStateException: contentPane cannot be set to null.
at java.desktop/javax.swing.JRootPane.setContentPane(JRootPane.java:594)
at java.desktop/javax.swing.JFrame.setContentPane(JFrame.java:679)
at com.AdamT.MergeSortGui.<init>(MergeSortGui.java:18)
at com.AdamT.MergeSortGui.main(MergeSortGui.java:13)
My code:
package com.AdamT;
import javax.swing.*;
class MergeSortGui extends JFrame {
private JPanel panel;
private JTextField inputList;
private JButton submitButton;
private JLabel inputLabel;
private JLabel outputLabel;
public static void main(String[] args) {
new MergeSortGui();
}
MergeSortGui() {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setContentPane(panel);
this.setTitle("MergeSort GUI");
this.add(inputList);
this.add(submitButton);
this.add(inputLabel);
this.add(outputLabel);
this.pack();
this.setVisible(true);
}
}
I would add my form, too, but I can't because then this woudld be mostly code... I uploaded all of my project here. From what I have seen from the error, it is because it's assuming that the content of each variable is null, even though it's taken care of by my .form
file. Any ideas?
(I know this is a dupe of this, but that has no working answer so I really am at completely lost)