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

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.

Thank you, this sounds like good idea and I will give it a try. I never thought of this, I was trying assign a Jpanal variable to a content area pane and then change the value of Jpanel variable on the basis of button pressed. – ravi May 8 '09 at 17:31.

I think CardLayout is probably what you want, but if something like memory usage is a concern and you really want to remove and add a new JPanel/Component, you need to remove the old JPanel and add the new one (with proper constraints and/or index depending on the layout). You'll have to validate() the content pane after you make the switch.

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?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions