• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Right-Click on JMenuItem

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. I have a JMenuItem that gets added to a JMenu and I'd like to add a popup menu that gets displayed when I right-click on the menu item (and the underlying menu still stays visible), and when I left-click on the menu, it performs its normal action. Does anyone know how to do this?

Thanks,
Jeff
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I spent a little bit of time with this tonight. Couldn't get it perfect, but maybe this will get you started:

 
Jeff Storey
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gregg. I appreciate the start on this code. I think some of that popup code will be useful, but I think I may need to create my own MenuUI. I was doing some digging to find out where the mouse events are processed and it appears to be in the BasicMenuUI. So, I think I have one of two options: either remove the mouse listeners from the menu that already exist and then add my own (but I think this might be a little risky since who knows what other mouse listeners are on the menu item) or create my own MenuUI.

I'm thinking this is not such a simple problem (while I do a lot of Swing programming, creating my own UI classes such as this is not something I do often). Thanks for the help.

Jeff
 
A timing clock, fuse wire, high explosives and a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic