(Java) JPopupMenu won't close if I click outside of it
- by Danny King
Hi all,
I have created a Java Swing app that has no visible main window but which is controlled through its tray icon by right-clicking.
I am using a JPopupMenu for this, but when I click outside of the popup menu (e.g. on another application's window or the desktop) the JPopupMenu does not disappear which is not the expected behaviour.
Originally I was using a popupMenu which did work as expected but this did not allow me to have icons in the menu.
How can I get it to close when I click elsewhere, as expected?
Thanks!