title: Why does a JLabel Component not convert into a JLabel, yet doesn't give any errors?
body: <p>Okay, so I have this JFrame frame and I'm trying to load all of the components into a JLabel ArrayList. the frame has a LayeredPane and around 20 JLabels scattered across. Some of them have a different z-index/layer index</p>
  <pre><code>   ArrayList&lt;JLabel&gt; labelList = new ArrayList&lt;&gt;();
      
      for(Component i : frame.getComponents() ) {
          
          
          if (i instanceof JLabel) {
              labelList.add((JLabel) i);
          }
      }
      
      System.out.println(labelList);
  </code></pre>
  <p>but when I try to print out the ArrayList, it just prints an empty Array.</p>
  <p>When I hover over the .getComponents(), it actually shows that all of the JLabels are in fact contained in the method.</p>
  <p>And it doesn't give out any errors either, like Component not being able to convert to JLabel etc.</p>
  <p>edit: I did as @camickr suggested, and it show that only the contentPane is grabbed. I probably misunderstood how the .getComponents() works.</p>
  <p>edit2 just changed the code to:</p>
  <pre><code>    ArrayList&lt;JLabel&gt; labelList = new ArrayList&lt;&gt;();
      
      for(Component i : layeredPane.getComponents() ) { //layeredPane being the name of the JLayeredPane, suprisingly
  
              labelList.add((JLabel) i); 
      }
      
      System.out.println(labelList.toArray().length);
  </code></pre>
  <p>And it works.
  I am a very dumb indiviudal.</p>