Java MVC - how to change view - JPanel
<p>I am creating to learn MVC in Java. I read that Java app with few JFrames is bad idea and better solution is to use JPanel. JDialog also does not solve the problem, because then I have too many of them. I have the MainFrame with a few buttons and my question is - how to change JPanels on the Frame after click on one these buttons?
I know how to change view if the View is Frame...</p>

<pre><code>//ActionListener in the MainController
public void actionPerformed(ActionEvent e) {

                    TheView theView2 = new TheView(); //TheView extends JFrame
                    TheModel theModel2 = new TheModel();        
                    TheController theController = new TheController(theView2,theModel2);
                    theView.setVisible(false);
                    theView2.setVisible(true);
     }
</code></pre>

<p>..but I have no idea, how to change only panels on the one frame? 
I know, that i have to add the listener to the button in the View and then in Controller add the rest of code (like above), but what do I need to change the view in the Controller? And should I do it in MainController or in the MainFrameController?
Below is how to this app should work:</p>

<ol>
<li>At the beginning is showing up the MainFrame with visible Panel1.</li>
<li>User click Button1.</li>
<li>Othe same MainFrame is showing Panel2.</li>
</ol>

<p>And so on with Panel3, 4...</p>

<p>Thanks for help.</p>

<p>EDIT: Yes, I know CardLayout and TabbedPane and I can use them, but I don't know how to apply this solution in MVC. "I just need answer how specifically should look like this piece of code with the change of the JPanel." And where should it be. In the MainController? In the MainFrameController?</p>