2

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.

enter image description here

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
user1992697
  • 315
  • 1
  • 5
  • 11

2 Answers2

4

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

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
  • @sansix if your up to an example, let me know and I'll up vote you ;) (on the iPad at the mo) – MadProgrammer Feb 03 '13 at 06:44
  • +1Mad... @user1992697 See [this](http://stackoverflow.com/questions/14011397/how-to-add-jpanel-by-clicking-jbutton/14012757#14012757) example (at bottom of post) to help you out. – David Kroukamp Feb 03 '13 at 13:44
1

try this,

            MainPanel.revalidate();
            MainPanel.add(SecondPanel);
            MainPanel.revalidate();
            firstPanel.setVisible(false);
            SecondPanel.setVisible(true);
            validate();
Praneeth Pj
  • 301
  • 6
  • 17