int (ButtonGroup group) { final ButtonModel selection = group.getSelection(); if (selection == null) return -1; final Enumeration<AbstractButton> buttons = group.getElements(); for (int i = 0; buttons.hasMoreElements(); i++) { final AbstractButton button = buttons.nextElement(); if (group.isSelected(button.getModel())) return i; } return -1; }