changing the color of JMenuItem when mouse is over it for our oxygen plugin

Post here questions and problems related to oXygen frameworks/document types.
vishwavaranasi
Posts: 144
Joined: Fri Feb 28, 2020 4:02 pm

changing the color of JMenuItem when mouse is over it for our oxygen plugin

Post by vishwavaranasi »

Hello Team , for changing the color of JMenuItem when mouse is over it for our oxygen plugin

inside the method we did like this
pluginWorkspaceAccess.addMenuBarCustomizer()
{
UIManager.put("MenuItem.selectionBackground",Color.GREEN);
UIManager.put("MenuItem.selectionForeground", Color.GREEN);
UIManager.put("MenuItem.opaque", Color.GREEN);

}

but this is not working.

any suggestions?
Thanks,
vishwa
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: changing the color of JMenuItem when mouse is over it for our oxygen plugin

Post by Radu »

Hi,

Maybe you can try to create a small Java swing application, google online how to change the JMenuItem color on hover, once you have a working solution you can go back to the plugin.
I would advice in general for accessibility reasons against changing the default background/foreground colors for menu items, labels, buttons. For example Oxygen has multiple color themes (Preferences->Appearance), once you start changing colors you may break the color themes for example for the dark color theme (Graphite).

Also once your plugin gets called, Oxygen has already used the "UIManager" colors for most of its components so setting values there might not help.
JMenuItems can have also HTML content for their text, something like: "menuItem.setText("<html><span color='red'>hello</span></html>")" but this might not work for the main menus on Mac OS where the main menu bar is a native menu bar and does not support HTML.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
vishwavaranasi
Posts: 144
Joined: Fri Feb 28, 2020 4:02 pm

Re: changing the color of JMenuItem when mouse is over it for our oxygen plugin

Post by vishwavaranasi »

Thanks Radu , we will consider that not to change colors.

Thanks,
vishwa
Thanks,
vishwa
Post Reply