Java 如何使用在 IntelliJ IDEA 中创建的 GUI 表单

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3899525/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 06:30:41  来源:igfitidea点击:

How to use GUI form created in IntelliJ IDEA

javauser-interfaceswingintellij-idea

提问by Dmitriy

I'm create simple gui form with one button in IntelliJ IDEA 9. Class wich was created with form is not JFrame or any another swing class. How I can call my form in my source code?

我正在用 IntelliJ IDEA 9 中的一个按钮创建简单的 gui 表单。使用表单创建的类不是 JFrame 或任何其他 Swing 类。如何在我的源代码中调用我的表单?

采纳答案by Colin Hebert

Simply go into the class associated with your form, press alt+ insertand choose "Form main()".

只需进入与您的表单关联的类,按alt+insert并选择“Form main()”。



Resources :

资源 :

回答by rem

I was stumped when IntelliJ consistently errored out when choosing Form main()from the insert menu, with an error message saying something about an invalid root component.

当 IntelliJ 在Form main()从插入菜单中选择时始终出错时,我被难住了,错误消息说明了无效的根组件。

It turns out it means that the JPanelthat is the main (root) component of your Formneeds to have a field bound to it, and by default it doesn't do this.

事实证明,这意味着它JPanel是您Form需要绑定一个字段的主要(根)组件,默认情况下它不会这样做。

Simply select the JPanelin the form designer, and give it a name (field name) in the property pane.

只需JPanel在表单设计器中选择,并field name在属性窗格中为其指定名称 ( )。

After this it will generate the main()just fine.

在此之后,它将生成main()就好了。