So you've discovered the beauty and utility of CardLayout. I hope it proves to be as appropriate for you as I imagined it.
Type: Posts; User: GregBrannon
So you've discovered the beauty and utility of CardLayout. I hope it proves to be as appropriate for you as I imagined it.
Reusing components already in the view as you are now doing is a much better approach than swapping one component for another or adding new ones on the fly.
If you need this functionality, you can...
It seems you may be adding the subPanel after the GUI is already on the screen. Is that correct? If so, are you revalidate()ing the container? Also, adding/removing components on the fly is...
So now the JPanel you've added to the center can have its own layout to which you can add other containers and components. It helps to draw out what you think the finished GUI should look like then...
How did you get 5 JButtons in the center?