Right-click on a menu item and popup a context menu

91 views Asked by At

I am using Java/Swing to add a JMenu with JMenuItem's. I want to add some optional complex actions to each menu item, but without having to add more cluttering hierarchical menus.

Is it possible to capture a right-click on a JMenuItem and use this event to open a JPopupMenu context menu? When I try to right-click on a JMenu item the event is consumed to perform the menu action. Is it possible to intercept and override this with a mouselistener?

My intended behaviour is:

  • left-click do menu action
  • right-click show popup menu
0

There are 0 answers