javaswingjpopupmenujpopup

How do I fire click() event whenever i click on any item in the popupmenu in java?


I want to add a window on clicking the menu item of a right click popupmenu in Java swing(seems like a simple task...but not getting)

I got it to partly work by

adding a custom menuitem in popupmenu
adding a window on right click

But this only partly works. Now I when I right click anywhere a window pops up, but the selected menu item in the popupmenu does not pop up the window. How can I get window on clicking my menu item? or is there an easier way to do this in java?

I know there are others ways of doing this (in code), but I would prefer to use Java swing

Has anyone ever done this before?

Thanks for your help


Solution