Is there a way to cancel the popup menu within popupMenuWillBecomeVisible()?
<p>In my java app, I've been using the <strong>popupMenuWillBecomeVisible()</strong> event to decide on which menu-items within my JPopupMenu will be enabled/disabled/visible/hidden, etc.</p>

<p>I've used the JPopupMenu as a right-click context menu of a JList, and I decide on the state of the menu-items depending on which item in the list was right-clicked.</p>

<p>This is all working fine. The only gotchya I have is for the case where the list is empty, or the right-click was triggered when no item was selected.</p>

<p>For this case, I was hoping that I could cancel the appearance of the JPopupMenu from within the <strong>popupMenuWillBecomeVisible()</strong> event, as that's where I currently perform my existing tests.</p>

<p>Is there a way to do this? Perhaps some sort of way to 'consume' the event?</p>

<p>If not, perhaps my only other option will be to try alternatives, such as moving the testing logic somewhere else, prior to the right-click.</p>

<p>Still, my preference at this stage was to keep the logic within popupMenuWillBecomeVisible(), unless that proves to be impossible.</p>

<p>Anyone got any ideas?</p>