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

welcome on this forum

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

Jump to Post

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 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.