<p>I have a swing application that includes radio buttons on a form. I have the <code>ButtonGroup</code>, however, looking at the available methods, I can't seem to get the name of the selected <code>JRadioButton</code>. Here's what I can tell so far:</p>

<ul>
<li><p>From ButtonGroup, I can perform a <code>getSelection()</code> to return the <code>ButtonModel</code>. From there, I can perform a <code>getActionCommand</code>, but that doesn't seem to always work.  I tried different tests and got unpredictable results.</p></li>
<li><p>Also from <code>ButtonGroup</code>, I can get an Enumeration from <code>getElements()</code>.  However, then I would have to loop through each button just to check and see if it is the one selected.</p></li>
</ul>

<p>Is there an easier way to find out which button has been selected?  I'm programing this in Java 1.3.1 and Swing.</p>

I would just loop through your
```
JRadioButtons
```
and call
```
isSelected()
```
. If you really want to go from the
```
ButtonGroup
```
you can only get to the models. You could match the models to the buttons, but then if you have access to the buttons, why not use them directly?