When I create a GUI form in IntelliJ IDEA, clicking on the Preview menu item creates the Error:
Cannot preview form '.../Main.form' Reason: Class not found: javax.swing.JPanel
However, manually creating a main method in the linked class and running the latter, will create my application window without problems:
public static void main(String[] args) {
JFrame frame = new JFrame("UBPrivacy");
frame.setContentPane(new Main().panel1);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
In my project structure, I have chosen Project SDK: java 9.0.1
In my platform settings, SDK 9.0 has all the necessary paths configured (java.desktop, etc.).
I wonder if this is an IntelliJ IDEA bug or if I somehow misconfigured my classpath, modules or something else. (Since my manual main RUN works successfully.)
Thanks in advance for any help on this topic.
On the main menu, choose File | New. On the pop-up menu, choose GUI Form. Specify the name of the new form, and select the layout manager. Check the option Create bound class, and specify the bound class name.
The JFormDesigner preferences are fully integrated into the IntelliJ IDEA settings dialog. Select File > Settings from the menu to open it, expand the "Other Settings" node and then select the "JFormDesigner" page. To set project specific settings, select the item named "JFormDesigner (Project)".
2 Years late and the bug still persists...
For anyone that re-discovered this question. You need to downgrade your project SDK from Java 9,10,11 to Java 8
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