title: How to delete all components in a JPanel dynamically
body: <p>Requirement is that i have 2 panels and ie. Panel1 , Panel2. Panel1 will have 2 button, when i click on any button, then Panel should should dynamically show components that are specific to that button on Panel1.</p>
  
  <pre><code>public class ListenerForRadioButton implements ActionListener{
  
  JButton browseGlobal;
  JFrame ParentFrame = new JFrame("Bla-Bla");
  JPanel ChildPanel2 = new JPanel();
  JButton upload ;
  
  public ListenerForRadioButton(JFrame JFrameConstructor, JPanel JPanelConstructor, JButton uploadConstructor ){
      this.ParentFrame = JFrameConstructor;
      this.ChildPanel2 = JPanelConstructor;
      this.upload = uploadConstructor;
  }
  
  public void actionPerformed(ActionEvent event){
  
      //ChildPanel2.remove(upload);
      ChildPanel2.remove(upload);
      System.out.println("My listener is called");
  </code></pre>
  
  <p>}//end of method
  }//end of class</p>
  
  <p>Public class Create_JFrame extends JFrame{</p>
  
  <pre><code>public Create_JFrame(){
  
       //Create a Frame
       JFrame ParentFrame = new JFrame("Bla-Bla");
       JPanel ChildPanel1 = new JPanel();
       JPanel ChildPanel2 = new JPanel();
       JButton Option1 = new JButton("Option1");
       JButton browse = new JButton("Browse");
       JButton upload = new JButton("Upload");
  
       //Layout management
       ParentFrame.getContentPane().add(BorderLayout.WEST, ChildPanel1);
       ParentFrame.getContentPane().add(BorderLayout.EAST, ChildPanel2);
  
  
       //Create a button
       browse.addActionListener(new ListenerForRadioButton(ParentFrame,ChildPanel2,upload)); //Registering my listener
  
       ChildPanel2.add(browse);
       ChildPanel2.add(upload);
       ChildPanel1.add(Option1);
  
  
       //Make the frame visible
       ParentFrame.setSize(500, 300);
       ParentFrame.setVisible(true);
      }//end of Main
  }//end of Class
  </code></pre>