Here you can find the source of getSelectedButtonText(ButtonGroup buttonGroup)
public static String getSelectedButtonText(ButtonGroup buttonGroup)
//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 String getSelectedButtonText(ButtonGroup buttonGroup) { for (Enumeration<AbstractButton> buttons = buttonGroup.getElements(); buttons.hasMoreElements();) { AbstractButton button = buttons.nextElement(); if (button.isSelected()) { return button.getText(); }/*from www . j a v a 2 s.c om*/ } return null; } public static boolean isSelected(AbstractButton... buttons) { for (AbstractButton button : buttons) { if (button.isSelected()) { return true; } } return false; } }