genghis cohen
genghis cohen

Reputation:

What event would I need to be able to tell that the mouse was moved over a JMenuItem?

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.

Upvotes: 0

Views: 94

Answers (1)

Clint
Clint

Reputation: 9058

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

Upvotes: 2

Related Questions