Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA - GUI Designer - Cannot preview form

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.

like image 595
Andres R Avatar asked Dec 27 '17 20:12

Andres R


People also ask

How do I run an IntelliJ GUI form?

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.

How do I use Jform designer in IntelliJ?

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)".


1 Answers

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

like image 125
Equinox Quasar Avatar answered Sep 27 '22 20:09

Equinox Quasar