tags:

views:

35

answers:

1

I'd like to handle the case where the mouse goes over any of the JMenuItems. I don't need the user to click one of the JMenuItems; simply to move the mouse over any of them. Basically, he has to click the JMenuBar to show the menus, but he doesn't have to click any menu item.

I wanted to use an actionPerformed listener on the JMenuBar - since the menu items and submenus only appear once the user clicks the JMenuBar - but that doesn't seem to be possible, unless I did something wrong.

+2  A: 

Implement a MouseListener and add it to the JMenuItems. Then you can catch when the mouse enters and leaves each JMenuItem.

Clint
Specifically, mouseEntered and mouseExited are the methods you need to implement.
David Zaslavsky