Java tutorial
//package com.java2s; import java.util.Enumeration; import javax.swing.AbstractButton; import javax.swing.ButtonGroup; public class Main { public static int getButtonGroupSelectIndex(ButtonGroup bg) { if (bg.getButtonCount() <= 0) { return -1; } Enumeration<AbstractButton> bEnum = bg.getElements(); for (int i = 0; bEnum.hasMoreElements(); i++) { AbstractButton temp = bEnum.nextElement(); if (temp.isSelected()) { return i; } } return -1; } }