How can I create (instantiate) and dispose of my forms created with IntelliJ's GUI builder from a custom class file?

Answered

I have created a form with IntelliJ's GUI builder, it has a working main() method, the form works properly and has some listeners attached.

In addition to that I have a custom class where I want to call that GUI I created with IntelliJ's GUI builder. I can accomplish this by copying the code within the "main" method in the GUI's class and placing it in my custom class and if I run my custom class the form is indeed displayed.

But thats about all I can do with the created GUI, I can only call it. I can't do other things like dispose that GUI form instance (frame.dispose()) and open another form because I don't know how to get access to the frame instance from my custom class.

Can someone please assist me with this? I thought it would save me a lot of time if I used the GUI builder as opposed to writing the GUI code from scratch for several forms.

Thanks

0
1 comment

>I can't do other things like dispose that GUI form instance (frame.dispose()) and open another form because I don't know how to get access to the frame instance from my custom class.

What is the issue accessing the frame? Why can't you create a class component which wraps the form (e.g. extends the awt dialog or form) containing the components you have created with designer?

Note, you can also select Generate GUI into Java source files in GUI Designer settings, then IDE will write Java source code for the form and its components to the source file of the class to which the form is bound, on compiling. It is helpful if you want the java class for the forms be completely isolated into the source code.

0

Please sign in to leave a comment.