Here you can find the source of getButtonSelectedInt(ButtonGroup buttonGroup)
public static int getButtonSelectedInt(ButtonGroup buttonGroup)
//package com.java2s; //License from project: Open Source License import javax.swing.ButtonGroup; public class Main { public static int getButtonSelectedInt(ButtonGroup buttonGroup) { try {//from w ww . j a va2 s. com return Integer.parseInt(getButtonSelectedString(buttonGroup)); } catch (NumberFormatException e) { return -1; } } public static String getButtonSelectedString(ButtonGroup buttonGroup) { return buttonGroup.getSelection().getActionCommand(); } }