How to switch bewteen panels in WindowBuilder (Java)

DudiD picture DudiD · Dec 2, 2011 · Viewed 9.2k times · Source

i'm using Windowbuilder in Eclipse indigo.

I have a main JPanel, and I want to add a new Panel which will popup when I click a button. How can I see the new Panel insted of the main panel in the Design frame?

thanks!

Answer

l5p4ngl312 picture l5p4ngl312 · Dec 2, 2011

There should be a window that is part of the Structure View called "Components". Click on the new JPanel from there. I did this a while ago but I do not currently have windowbuilder installed so I am not 100% positive. I will confirm it when I can.

Edit: Ok i took a look at it. Here's how it works. If you made a new Application Window, make sure the palette view is open (Window->Show View->Palette). Now I am pretty sure the best way to switch between panels is by using a card layout. So drag the card layout from the palette to the window. Now if you drag JPanels from the palette to getContentPane() in the components window, you can switch between those panels with buttons and such.