Reputation: 5086
I'm using WindowsBuilder (Eclipse) to generate a simple GUI. Basically, I have a series of buttons ("Add Book", "Add DVD", "Add Magazine", etc..) add the top of the gui, and a JPanel underneath them. I would need to display a different series of elements (textfields, radio buttons etc) depending on which button the user presses. I have understood the basics of adding elements, but how can I define these multiple panel structures?
Thanks :)
Upvotes: 0
Views: 437
Reputation: 324118
I would need to display a different series of elements (textfields, radio buttons etc) depending on which button the user presses.
You should be using a CardLayout which will allow you to swap panels depending on the button pressed. Read the section from the Swing tutorial on How to Use Card Layout work a working example.
Upvotes: 1