简体   繁体   English

IntelliJ IDEA - GUI 设计器 - 无法预览表单

[英]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:当我在 IntelliJ IDEA 中创建 GUI 表单时,单击预览菜单项会创建错误:

Cannot preview form '.../Main.form' Reason: Class not found: javax.swing.JPanel无法预览表单 '.../Main.form' 原因:找不到类:javax.swing.JPanel

However, manually creating a main method in the linked class and running the latter, will create my application window without problems:但是,在链接类中手动创建一个 main 方法并运行后者,将毫无问题地创建我的应用程序窗口:

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在我的项目结构中,我选择了 Project SDK:java 9.0.1
In my platform settings, SDK 9.0 has all the necessary paths configured (java.desktop, etc.).在我的平台设置中,SDK 9.0 配置了所有必要的路径(java.desktop 等)。

I wonder if this is an IntelliJ IDEA bug or if I somehow misconfigured my classpath, modules or something else.我想知道这是一个 IntelliJ IDEA 错误还是我以某种方式错误地配置了我的类路径、模块或其他东西。 (Since my manual main RUN works successfully.) (因为我的手动主 RUN 运行成功。)

Thanks in advance for any help on this topic.在此先感谢您对本主题的任何帮助。

2 Years late and the bug still persists... 迟了2年,虫子仍然存在......

For anyone that re-discovered this question. 对于那些重新发现这个问题的人。 You need to downgrade your project SDK from Java 9,10,11 to Java 8 您需要将项目SDK从Java 9,10,11降级到Java 8

I found the right way is set我发现正确的方法是设置

"javac2.instrumentation.includeJavaRuntime=true " in build.properties file build.properties 文件中的“javac2.instrumentation.includeJavaRuntime=true”

you can try it你可以试试看

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM