I have menu in my application, and I want to set menu item normal state icon, and pressed state icon. Normal state icon is added, but when I press menu item, normal state icon is not changed by pressed state icon. What is problem here:
JMenu m=new JMenu(text);
m.setBackground(getTheme().colors.menuColor());
m.setOpaque(false);
m.setIcon(core.getIcon(text, "normal"));
m.setPressedIcon(core.getIcon("webmaps", "pressed"));
This issue has been seen before. The inherited setPressedIcon does not change the background
Icon
on the theJMenu
(or indeedJMenuItem
). You could use aMenuListener
on the component as a workaround: