select all check boxes in a window
<p>I'm new with in java, adn I have some check boxes and a button on a window, I want when I click on this button to select all check boxes in the window.</p>

<p>In C# I was using this :</p>

<pre><code>foreach (Control c in this.Controls) {
    if ((c) is CheckBox) {
        c.Checked = true;
    }
}
</code></pre>

<p><strong>How can I do this in Java ?</strong></p>

<p>this is the code I tried </p>

<pre><code>for (Component c : this.getComponents()) {
   if(c instanceof JCheckBox)
       c.setSelected(true);
}
</code></pre>
