(Java) JPopupMenu won't close if I click outside of it
<p>I have created a Java Swing app that has no visible main window but which is controlled through its tray icon by right-clicking.</p>

<p>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.</p>

<p>Originally I was using a popupMenu which did work as expected but this did not allow me to have icons in the menu.</p>

<p>How can I get it to close when I click elsewhere, as expected?</p>

<p>Thanks!</p>
