In short, no I don't believe that there is any quick way of finding the
inext of the selected radioButton as it stands. It seems that the
ButtonGroup is just treated as an unordered collection of ButtonModels.
Well, Not entirely. You can extend the functionality of the ButtonGroup by
creating an internal class and add a function that returns the index of the
selected Button model. "buttons" is a protected Vector so it does store the
order of the ButtonModels. It's a relatively small change to your
ButtonGroup class.

public class MyClass {

    public class MyButtonGroup extends ButtonGroup {

      public int indexOf(ButtonGroup b) {
        return buttons.indexOf(b);
      }

    }
    private MyButtonGroup bg = new MyButtonGroup();


}

> -----Original Message-----
> Hello All,
> Say I have a number of JRadioButton's in a ButtonGroup. We assume that
> radio buttons have indices 0, 1, 2, .... Is there a quick way of finding
> out the index of the selected radio button in that group?
>
> I really need this. Thanks a lot in advance,

_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing

Reply via email to