title: Adding ArrayList of JLabels into JPanel
body: <p>I'm currently experimenting with Java where I've created a JFrame to pop up on the screen when the program is executed. </p>
  
  <p>I have also created an ArrayList of JLabels and a for loop to recursively add JLabels into the array. </p>
  
  <p>Up to this point, I 'think' I've succeeded, but now I want to be able to use this ArrayList to recursively add the elements of the ArrayList into visual JLabels inside my Jframe.</p>
  
  <p>Here is my whole code (It's only small) </p>
  
  <pre><code>public class Executable {
       private static JFrame view; 
       private static JLabel image; 
  
  public static void main(String[] args) { 
      view = new JFrame("adding labels"); 
      view.setBounds(0,0,300,1000); 
      view.setLocationRelativeTo(null);
      view.setVisible(true); 
  
      ArrayList&lt;JLabel&gt; label = new ArrayList&lt;JLabel&gt;(); 
  
      for(int i=0; i &lt; 20; i++) { 
          image = new JLabel("Test"); 
          image.setText("image-icon-"+i);
          image.setBounds(0,0,200,200); 
          image.setBackground(Color.green); 
          image.setOpaque(true); 
          label.add(image); 
      }
  
      JPanel p = new JPanel(); 
  
      for (JLabel j:label) { 
          p.add(j); 
      } 
      view.add(p); 
  }
  }
  </code></pre>
  
  <p>Thanks in advance for anyone who could offer assistance. </p>