Check out example codes for "how to remove all components from layeredPane java". It will help you in understanding the concepts better.

Code Example 1

void    remove(int index)

Code Example 2

panel.revalidate();
 panel.repaint();

Code Example 3

removeAll()

Code Example 4

remove(Component comp)

Learn ReactJs, React Native from akashmittal.com