Java Swing Radio Button example:
Output:
here is output |
Source code:
private void showRadioBtnExampleActionPerformed(java.awt.event.ActionEvent evt) {
maleRadioBtn.setActionCommand("Male");
feMaleRadioBtn.setActionCommand("Female");
JOptionPane.showMessageDialog(null,"You have selected "+buttonGroupGender.getSelection().getActionCommand());
}
Watch Video Here: