Page 1 of 1
changing the color of JMenuItem when mouse is over it for our oxygen plugin
Posted: Tue Oct 18, 2022 12:20 pm
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?
Re: changing the color of JMenuItem when mouse is over it for our oxygen plugin
Posted: Tue Oct 18, 2022 2:48 pm
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
Re: changing the color of JMenuItem when mouse is over it for our oxygen plugin
Posted: Wed Oct 19, 2022 2:17 pm
by vishwavaranasi
Thanks Radu , we will consider that not to change colors.
Thanks,
vishwa