Here you can find the source of parseLevel(ButtonGroup buttonGroup)
private static int parseLevel(ButtonGroup buttonGroup)
//package com.java2s; //License from project: GNU General Public License import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import java.util.Enumeration; public class Main { private static int parseLevel(ButtonGroup buttonGroup) { Enumeration<AbstractButton> buttonEnumeration = buttonGroup.getElements(); while (buttonEnumeration.hasMoreElements()) { AbstractButton abstractButton = buttonEnumeration.nextElement(); if (abstractButton.isSelected()) { String buttonText = abstractButton.getText(); final int index = buttonText.indexOf(" ("); if (index != -1) { buttonText = buttonText.substring(0, index); }/*from www . java 2s. co m*/ return Integer.parseInt(buttonText); } } return -1; } }