Change JPanels within JFrame using NetBeans GUIBuilder

663 views Asked by At

I'm making a GUI project in NetBeans. I have a JFrame and 3 JPanels. Only one of the JPanels should be displayed at a time. The JPanel that is displayed should be changed using a menu option (the listeners work).

My question is, how do I switch them out? I've tried removing the old JPanel and putting in the new JPanel. I've tried adding a fourth JPanel into the JFrame and having all three JPanels exist within the fourth, so I can use removeAll() (bad technique, but I was desperate). I've tried redirecting the object reference so that it points to the new JPanel instead of the old one. In each case, I've finished off the code snipped with

    revalidate();
    repaint();

To no avail. I've seen a lot of talk about CardLayout and GroupLayout but I have no idea how to implement them using the NetBeans GUIBuilder. Could one of you fine people tell me how to switch out the JPanels?

1

There are 1 answers

0
LastStar007 On BEST ANSWER

Use a LayeredPane. 30charactermin