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

Code Example 1

private JFrame frame = new JFrame();
 ...
 ...
 frame.getContentPane().removeAll();
 frame.repaint();

Learn ReactJs, React Native from akashmittal.com