title: Adding 2 or more objects to JFrame
body: <p>I want to display 2 objects on JFrame. I tried by adding objects to JPanel and then add JPanel to JFrame but it also did not work.  I also tried to add ball and ball1 objects directly to JFrame but it shows the last added object only. I want to show both objects on JFrame at a time.  The below given code only shows ball1 object. </p>
  
  <pre><code>    JFrame f = new JFrame("Moving"); 
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
      //making 2 objects 
      Ballbewegung2 ball = new Ballbewegung2();
      Ballbewegung3 ball1 = new Ballbewegung3(); 
      JPanel contentPane = new JPanel(new BorderLayout());
      JPanel contentPane1 = new JPanel(new BorderLayout());
  
      //adding objects to JPanel
      contentPane.add(ball, BorderLayout.CENTER);                 
      contentPane1.add(ball1, BorderLayout.CENTER);                 
  
      //Adding JPanel to JFrmae
      f.getContentPane().add(contentPane);
      f.getContentPane().add(contentPane1);
      f.setSize(500, 500);
      f.setVisible(true);  
  </code></pre>