i have 2 jbuttons in my java application. I have 2 jpanels too. these 2 jpanels have different contents i.e not related to eachother. now I want that whenever a user clicks a button then the corresponding jpanel should be displayed but at the same location( the jpanels have different width & height).
when i tried to do it in netbeans one jpanel is included inside another jpanel
private void button1ActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
button1panel.setVisible(true);
//all other panel's visibility is false
}
like that for button2 i have actionlistener like this
private void button2ActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
//all other panel's visibility is false
button2panel.setVisible(true);
}
i have placed these 2 panels one above another(button2panel over button1panel) so that i can access it in the same location
but as the button2panel is small in width & height when i call button2panel.setVisible(true) it actually not enabled.
my demonstration says that as the button2panel is inside the button1panel & the button1panel's visibility is false that's why its happening.
what can i do is just to take the button2panel outside the button1panel but if i do this then the panels location would be different
how to fix it??
or any better solution for this??