• Post Reply Bookmark Topic Watch Topic
  • New Topic

JMenuBar Rollover

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know how to write a mouseListener for a component(s), but what I need to know is what method call (if any) I can make on a JMenu that will fire the click event when the mouse enteres that component.
So that you don't have to click on the menu for it to drop down.
If there is not a method, will I have to use the Robot Class?
Thanks
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gregg,
This is a very interesting question, you have. I'm shure, many users will like it. I made a little test and at least I could popup the menu when the mouse was over and I could close the menu when the mouse exited. But this was easy. There is something more to do. You have to take care, that the popupmenu hides, when a menuitem is pressed.
Try this, maybe it helps you:

Regards
Rene
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rene. Maybe this would be a good little package to build and extend JMenuBar and re-use? Fun stuff.
Thanks again.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found an easier way. There is a doClick() method that does most of the work. Just regester a mouseListener and on the mouseEntered() method just do
public void mouseEntered(MouseEvent m) {
JMenu menu = (JMenu)m.getSource();
menu.doClick();
}
And that's it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!