dcsimg
Multiple JPanels in a JFrame.
4 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Sunday, November 18, 2001 10:02 AM

I am having multiple JPanels in a JFrame in a Program.


Depending on the selection of the Menu Item , only one panel should be visible at a time in the same position.


I have added all the panels to the contentPane and displaying using setVisible(true).


On displaying the second JPanel , It is not appearing.


I tried to remove the 1st Panel using setVisible(false) and contentPane.remove(panelname).


But the first Panel is not disappearing.


Kindly give the solution for this.

Re: Multiple JPanels in a JFrame.

Posted By:   Scott_Stanchfield  
Posted On:   Monday, November 19, 2001 02:21 PM

Create a JPanel with a CardLayout as its layout manager. Then add all of the JPanels you want to display in it.

You can then switch between the panels using the show("name") method of CardLayout.

Hope this helps!
-- Scott

Re: Multiple JPanels in a JFrame.

Posted By:   devaki_perumal  
Posted On:   Monday, November 19, 2001 01:28 AM

set the layout of the frame to cardlayout and add the panels u want to be on the Frame to the cardlayout.
in the menu action performed u show the card(the panel u want to be visible ).For card layout refer some tutorials

Re: Multiple JPanels in a JFrame.

Posted By:   devaki_perumal  
Posted On:   Monday, November 19, 2001 01:27 AM

set the layout of the frame to cardlayout and add the panels u want to be on the Frame to the cardlayout.
in the menu action performed u show the card(the panel u want to be visible ).For card layout refer some tutorials

Re: Multiple JPanels in a JFrame.

Posted By:   devaki_perumal  
Posted On:   Monday, November 19, 2001 01:26 AM

set the layout of the frame to cardlayout and add the panels u want to be on the Frame to the cardlayout.
in the menu action performed u show the card(the panel u want to be visible ).For card layout refer some tutorials
About | Sitemap | Contact