Here you can find the source of getSelectedButton(ButtonGroup group)
public static AbstractButton getSelectedButton(ButtonGroup group)
//package com.java2s; //License from project: Open Source License import java.util.Enumeration; import javax.swing.AbstractButton; import javax.swing.ButtonGroup; public class Main { public static AbstractButton getSelectedButton(ButtonGroup group) { Enumeration<AbstractButton> buttons = group.getElements(); while (buttons.hasMoreElements()) { AbstractButton button = buttons.nextElement(); if (button.isSelected()) { return button; }/*from w w w . ja v a 2 s . c om*/ } return null; } }