Home > OS >  Add Image to JMenu
Add Image to JMenu

Time:12-25

I can't for the life of me figure out how to add an icon besides the text on a JMenu. Everywhere I've looked on the internet I've only found how to add an icon on a JMenuItem but nothing on the JMenu itself. Can someone help me ? Thanks in advance.

CodePudding user response:

JMenu extends JMenuItem which in turn extends AbstractButton. Both JMenu and JMenuItem inherit setIcon from AbstractButton. This is the same method that gets called when you create a JMenuItem with an Icon in the constructor. For JMenu you'll have to call it separately.

  • Related