JRadioButtonMenuItem with ticking

I am wondering if it is possible to change the display of the default radio button menu item in Java Swing.

By default, a circle with a dot inside will indicate the selected state of the button, but I just want the old vintage tick next to the selected menu item and nothing to appear next to the item that is not selected. (All items in question are of type JRadioButtonMenuItem

)

I tried to use .setSelectedIcon(...)

which can be found here:

http://docs.oracle.com/javase/7/docs/api/javax/swing/AbstractButton.html#setSelectedIcon(javax.swing.Icon)

But nothing changed, there were no exceptions, and I still stuck to the look.

Any ideas?

+3


source to share


1 answer


Instead of using, JRadioButtonMenuItem

you can use JCheckBoxMenuItem

which is checked by default. JCheckBoxMenuItems

can also be owned by a ButtonGroup

, also giving you one select action shown JRadioButtonMenuItem

.



Example

+6


source







All Articles