[英]Swing GUI Builder Intellij IDEA
I can't seem to run a form on IntelliJ GUI builder 我似乎无法在IntelliJ GUI构建器上运行表单
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. 现在我只有一个
JPanel
,不管怎样它都没有自动初始化,即使它在设计师身上清晰可见。
It's a Gradle project and I've chosen to run with the generated main function. 这是一个Gradle项目,我选择使用生成的main函数运行。
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);
}
}
By default, the IntelliJ IDEA UI designer works by generating bytecode, which is unfortunately not supported with Gradle builds. 默认情况下,IntelliJ IDEA UI设计器通过生成字节码来工作,遗憾的是,Gradle构建不支持该字节码。 You can change it to generate source code in Settings |
您可以更改它以在“设置”中生成源代码 Editor |
编辑| GUI Designer.
GUI设计器。
see Intellij (Swing) GUI not compiling because of Gradle 因为Gradle,请参阅Intellij(Swing)GUI不编译
solved by changing intellij settings (also see the screenshot) 通过改变intellij设置解决(另见截图)
i've checked: 我检查过:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.