Problem regarding JPanel
i am using 3 JPanels in my prog. All are added to a JFrame , which contains 3 TollBarButtons. if i click on one toolbarbutton one Jpanel must appear. when making the JPanel visible i need to check which Jpnael is currently visible and make it hide.
How can it be possible?
Please send me the solution as quickly as possible.
thank u.
[360 byte] By [
bhuvana] at [2007-10-2 18:21:04]

set the frame as a cardlayout, add your 3 panels, with identifiers "0" "1" and "2",then the code for each toolbar button would becardLayout.show(container, identifier)
Hi
Better way U set ur JFrame layout as BorderLayout.then u can set ur toolbar on the top of the JFrame
getContentPane().add(toolbar,BorderLayout.NORTH);
after that u can create 3 JPanels.
if u r clicking on first button u can add first Panel to the center of JFrame using following command
getContentPane().add(panel1,BorderLayout.CENTER);
in the same way u can add other Panels also.
before adding other Panel u have to check the other two panel objects is null or not.
before adding the JPanel object u have to set as null other two JPanel objects.
for example if u r clicking first button that time u have to set as null other two panel objects
regards
pradeep
> Better way U set ur JFrame layout as BorderLayout.then u can set ur toolbar
> on the top of the JFrame
Yep, forgot about the toolbar, but a cardlayout is still the easiest option -
add a panel (cardlayout) to the frame, then add the other 3 panels to the
cardlayout panel