suhail
suhail

Reputation: 3

How to switch on from one panel to another by hiding the first panel on netbeans IDE

How do I switch from one panel to another by hiding the first panel in Netbeans IDE (ie: panel1.setVisible(false) and panel2.setVisible(true) as we click on a button belonging to first panel)? Please help me as Netbeans is strange to me.

Upvotes: 0

Views: 3053

Answers (1)

Nate W.
Nate W.

Reputation: 9249

Sounds like you want to use CardLayout to manage all the panels that you want to switch between, assuming that your panels will occupy the same space on the screen.

You'll need to create a component that uses the CardLayout layout manager and then add all the panels that you want to switch between to it. Then your various buttons that will switch panels can reference the layout manager and switch the panels accordingly - the CardLayout will manage calling the appropriate setVisible methods.

Upvotes: 2

Related Questions