JMenu as JRadioButtonMenuItem with submenu

816 Views Asked by At

I have a requirement where-in I have a JPopupMenu as a right click menu. I have some JMenus as part of the JPopupMenu which are like modes and all of them have sub menu options as SliderMenuItems(custom), JCheckBoxMenuItems and JRadioButtonMenuItems.

I need to have radio buttons for JMenus to indicate the selection of a mode and the behavior should be as in JRadioButtonMenuItem, i.e. the radiobutton should be selected on mouse-click and not on mouse-hover.

I was able to add radio button icon by extending the BasicMenuUI and setting the checkIcon in installDefaults method.

But I am not able to have that click behavior as in JRadioButtonMenuItem, since the JMenu selects the button icon on mouse over.

Can somebody please suggest a way to create a JMenu with radio button in the menu and a submenu with different menuitems.

1

There are 1 best solutions below

2
On