You can use the ==
to compare references as the references wont change.
if(e.getSource() == radBtn1){
// do something
}
I have used this in the past and it worked like a charm for me.
As for the class cast issue, you need to use instanceof
to check to what class the source of the event belongs. If the cause was a JButton
and you cast it to JRadioButton
blindly, it will result in an exception. You need this:
Object source = e.getSource();
if (source instanceof JButton){
JButton btn = (JButton) source;
} else if (source instanceof JRadioButton){
JRadioButton btn = (JRadioButton) source;
}