2 radio button groups

D

Duane Evenson

I would like to have a set of JRadioButtonMenuItem's and JRadioButtons
referring to the same group. Selecting the "red" radio button in the
menu will also set the "red" radio button on the panel. How do I go
about referring two or more radio buttons to the same group element.
All I can figure is having two groups, two listeners, and each listener
copy its changed group model to the other group.
Is there a more elegant solution?
 
V

Vova Reznik

Duane said:
I would like to have a set of JRadioButtonMenuItem's and JRadioButtons
referring to the same group. Selecting the "red" radio button in the
menu will also set the "red" radio button on the panel. How do I go
about referring two or more radio buttons to the same group element.
All I can figure is having two groups, two listeners, and each listener
copy its changed group model to the other group.
Is there a more elegant solution?

You may share ButtonModel:
redRadioButtonMenu.setModel(redRadioButton.getModel());
and add to a button group only one button from pair menu:button
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top