How to get multiple GUI froms?

Answered

Hey Guys,

 

It's the first time for me to use IntelliJ and to creat a GUI. But I have a question. How can I use multiple GUI froms?

Because I have a frame and need diffrent JPanels (Window views). But I just can design one Panel in the form? 
Can I creat another form and design there the second JPanel? - If yes, how can I change that later in the code?

11 comments
Comment actions Permalink

Do you mean multiple forms at the same time or you want to switch the form like it works in IDE settings, for example?

0
Comment actions Permalink

I want to design diffrent JPanels. So that I can change the content panel. But how can I design the other panels...

Thats my problem...

 

I have a main window. If some events happen, the content panel should change to a other... But first I must design the other panels... But where?

0
Comment actions Permalink

Create multiple forms with their own JPanels, add a getter that will return the root JPanel of the form, now you can use something like CardLayout on the main form to switch the displayed JPanel on some event by creating an instance of the required form and calling the getter.

0
Comment actions Permalink

I can't really follow you ... :/

I have a JFrame. In the JFrame is a rootPanel and in the rootPanel are 3 other JPanels. This 3 JPanels are the "start Panles".
But how can I design the other Panels?  Thats my problem... How can I use the GUI Designer for the other Panles?

This one! 

0
Comment actions Permalink

Create a new form+class for every JPanel, then with your own code add JPanel from another form to the main form.

0
Comment actions Permalink

What do you mean with "then with your own code add JPanel from another form to the main form"?

How can I get the JPanel from the other class?

0
Comment actions Permalink

As I said, you add a getter method that returns the root JPanel bound to the form.

0
Comment actions Permalink

ok, thank you

0
Comment actions Permalink

Hello Serge Baranov again,

I created now a extra class and form, but I have problems to get the root panel and to change the panel in my GRIDLayout...
Could you maybe send me a example of the Code, how it would like, to code the getter and how I can change the panel in my main frame to the panel from the getter?

 

Would be very nice!
Because I can't find anything how I can code that... :/

 

Thank you!

0
Comment actions Permalink

Depends on the use case, but one can use Custom create option to initialize certain components manually:

Sample project: https://www.dropbox.com/s/nj4ldtzqzc9re1i/NestedForms.zip?dl=0

0
Comment actions Permalink

Finally I programmed the server, the client and the gui but I have a huge problem...
It should be working but the GUI is freezing if I will change the content panel!

I tested the GUI ago I wrote the server and at that time it worked!
So I have no idea why the GUI doesn't change the content panel if I want to test it with the server... 

Here is my repository. I would be very happy if somebody could help me!

You can start the server with the Launcher.java class and an argument which is your port.
If you want to start the client. You also start the Launcher.java but WITHOUT any argument!
https://www.dropbox.com/s/zki74571fykontv/Quiz.rar?dl=0

Thanks a lot!

0

Please sign in to leave a comment.