Java tutorial
//package com.java2s; import java.util.Enumeration; import javax.swing.ButtonGroup; import javax.swing.JRadioButton; public class Main { /** * This method returns the selected radio button in a button group. * @param group the button group * @return the selected radio button */ public static JRadioButton getSelectedRadioButton(ButtonGroup group) { for (Enumeration e = group.getElements(); e.hasMoreElements();) { JRadioButton b = (JRadioButton) e.nextElement(); if (b.getModel() == group.getSelection()) { return b; } } return null; } }