Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use GUI form created in IntelliJ IDEA

I'm creating a simple GUI form with one button in IntelliJ IDEA 9. The class which was created with the form is not JFrame or any other swing class. How I can call my form in my source code?

like image 572
Dmitriy Avatar asked Oct 10 '10 08:10

Dmitriy


People also ask

What does IntelliJ use for GUI?

IntelliJ IDEA is a pure Java Swing application. All the custom components like editor tabs are created manually, no third-party libraries are used for this.

Can I create GUI in IntelliJ?

GUI Designer in IntelliJ IDEA enables you to create graphical user interfaces (GUI) for your applications using Swing library components. The tool helps you speed up the most frequent tasks: creating dialogs and groups of controls to be used in a top-level container such as a JFrame.


2 Answers

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.

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

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

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

like image 168
rem Avatar answered Oct 03 '22 04:10

rem


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


Resources :

  • GUI Designer Basics
like image 28
Colin Hebert Avatar answered Oct 03 '22 04:10

Colin Hebert