posted 12 years ago
You need to be sure that when you remove / add components you do so on the EDT and that you then call repaint() on the parent component (also on the EDT). I'm not sure if you need to invoke revalidate() on the parent before the call to repaint(), but I seem to recall that it's handled automagically when you add or remove components.
Edit: And to answer the actual question, no you don't have to remove every individual child component, you can simply remove the container i.e the JPanel.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.