
how to get an alert message when radio button is selected instead of checkbox

Java Alert Message
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class Validation{
public static void main(String[] args){
JFrame f=new JFrame();
f.setLayout(null);
final JRadioButton radio=new JRadioButton("Select");
final JCheckBox check=new JCheckBox("Check");
JButton b=new JButton("Check");
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
if(radio.isSelected()&&!check.isSelected()){
JOptionPane.showMessageDialog(new JFrame(), "You have selected radiobutton istead of checkbox", "Dialog",
JOptionPane.ERROR_MESSAGE);
}
}
});
radio.setBounds(10,10,100,20);
check.setBounds(10,40,100,20);
b.setBounds(10,70,100,20);
f.add(radio);
f.add(check);
f.add(b);
f.setVisible(true);
f.setSize(300,140);
}
}