I have a foreach loop that iterates all components in a jPanel, and I want to get the type of a components and check if it's a JRadioButton.
this is the code I tried:
for (Component c : ((Container)jPanel1).getComponents() )
{
if(((JRadioButton)c).isSelected() && c.getComponentType()) {
if(!listrep.contains(((JRadioButton)c).getText())) {
((JRadioButton)c).setForeground(new java.awt.Color(204, 0, 0));;
}
}
}
but it won't work.
How can I do that?