Java - Accessing JLabel inside JPanel
<p>I have a GUI that holds panels containing both a component and a label relating to this component. The labels are created and never changed, so at the moment, I just have their constructor in the <code>JPanel.add()</code> method.</p>

<pre><code>    //add label
    toServerPanel.add(new JLabel("Your Message"), BorderLayout.NORTH);
    //add component
    toServerPanel.add(toServer, BorderLayout.SOUTH);
</code></pre>

<p>This works fine, and they are fine as anonymous objects but I would now like to change the text colour of some or all of the labels within the application. Seeing as they are anonymous objects they can't be accessed by their variable name, but at the same time I don't want to have to created endless <code>JLabel</code> variables.</p>

<p>In the current situation, is the a method or function to access the <code>JLabel</code> objects by checking for objects inside the <code>JPanel</code>?
Alternatively, is there some kind of loop that could affect all the <code>JLabel</code> objects on the GUI?</p>

<p>Thanks,
Mark</p>