i'd like to ask how one can get rid of all the components in a JPanel (buttons, labels,
comboboxes etc), so that you can add new components (at run time that is)

Recommended Answers

All 3 Replies

welcome on this forum

can you be so little bit concrete, because there are areas or options or posibilities

You can iterate through all the children of the JPanel removing them one at a time... but it's probably easier to remove the old JPanel from your window and replace it with a new empty one.

its okay i've discovered a method jPanel.removeAll(), and it works fine. Thanks for your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.