Reputation: 315
Is it possible to have a frame where by a new panel in that frame refreshes to the next panel, if you click the 2 link for example.
Is there easy code for this?
The picture below illustrates this better.
Upvotes: 2
Views: 85
Reputation: 351
try this,
MainPanel.revalidate();
MainPanel.add(SecondPanel);
MainPanel.revalidate();
firstPanel.setVisible(false);
SecondPanel.setVisible(true);
validate();
Upvotes: 1
Reputation: 347314
You'll want to use a CardLayout, this is what it's designed for. It will allow you to switch out different components based on your needs
Check out How to use CardLayout for more info
Is there easy code for this?
That's a little subjective, but I would say CardLayout
is the simplest of the possible solitons
Upvotes: 4