Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I switch panels inside a frame depending on a button action?

I have created an application that has a toolbar, menubar and content area. I have added the menu and toolbar to the application window, but I am stuck with displaying the panel in content area based on the button action (like add, display) which is clicked through the toolbar. Is this a right way to do this? Is there any better way to do this?

like image 366
ranendra Avatar asked May 08 '09 17:05

ranendra


1 Answers

If I understand correctly, you want to have multiple JPanels, only one of which is shown at a time? If that's the case, it sounds like a CardLayout is what you need. You basically add all your JPanels to it with unique names, and then you can tell the CardLayout which of them to show.

like image 59
Michael Myers Avatar answered Oct 21 '22 20:10

Michael Myers