GUI
package Trial;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
class Demo extends JFrame implements ActionListener {
	JButton b1, exitbtn;
	JRadioButton r1, r2;
	Demo() {
		setTitle("Hancie e-Learning Studio");
		setLayout(null);
		setSize(600, 400);
		setLocationRelativeTo(null);
		r1 = new JRadioButton("Male");
		r1.setBounds(30, 20, 90, 40);
		add(r1);
		r2 = new JRadioButton("Female");
		r2.setBounds(130, 20, 90, 40);
		add(r2);
		ButtonGroup bg = new ButtonGroup();
		bg.add(r1);
		bg.add(r2);
		b1 = new JButton("Check");
		b1.setBounds(30, 130, 100, 40);
		add(b1);
		b1.addActionListener(this);
		exitbtn = new JButton("Exit");
		exitbtn.setBounds(150, 130, 100, 40);
		add(exitbtn);
		exitbtn.addActionListener(this);
		setVisible(true);
	}
	public void actionPerformed(ActionEvent ev) {
		if (ev.getSource() == (b1)) {
			if (r1.isSelected()) {
				JOptionPane.showMessageDialog(this, "Male is Selected");
			}
			if (r2.isSelected()) {
				JOptionPane.showMessageDialog(this, "Female is Selected");
			}
		}
		if (ev.getSource() == exitbtn) {
			System.exit(0);
		}
	}
	public static void main(String args[]) {
		new Demo();
	}
}
Output


