Reputation: 1641
Hello I have a main layout made in this way:
| |
Main pane |Menu pane|
| |
Now, menu pane is made just of button: clicking on a button switches main panel with another panel. On click event is made this way:
public void actionPerformed(ActionEvent evt){
mainPanel = new MyNewPanel();
this.revalidate();
}
But, for some reason, main panel does not change!
Upvotes: 2
Views: 1563
Reputation: 159754
You are not setting the main component of your container. You need to add your new panel and call validate()
on that container.
Note, depending on your the layout of your container you may need to remove the currently visible component first.
CardLayout could manage all this for you.
Upvotes: 7