Java tutorial
//package com.java2s; import java.awt.Component; import java.awt.Container; public class Main { private static void disassemble(Component component) { if (component instanceof Container) { Container container = (Container) component; int nSubcomponents = container.getComponentCount(); for (int i = 0; i < nSubcomponents; ++i) { disassemble(container.getComponent(i)); } container.removeAll(); } } }