JDK-4242595 : PopupMenuListener.popupMenuCanceled never called
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.1.7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1999-05-30
  • Updated: 1999-06-01
  • Resolved: 1999-06-01
Related Reports
Duplicate :  
Description

Name: dbT83986			Date: 05/29/99


It appears that as of Swing 1.1, PopupMenuListener.
popupMenuCanceled doesn't get called any more.  This was
supposed to be called if the user invoked a popup menu and
then clicked outside the menu area or iconified the application
frame.  I looked at the Swing 1.03 source, and there was code
in JPopupMenu.java to do this (in the MouseGrabber code), but
for some reason, the code doesn't exist in Swing 1.1.

I've personally implemented the workaround I specified in the report, so it's not a burning issue for me,
but I do think it's worth fixing to prevent future frustration by others.

I think I can clarify the source code issue I was talking about.  In 1.03,
if you look in src/com/sun/java/swing/JPopupMenu.java, there's an inner
class called MouseGrabber (beginning at line 1063 in the code I'm looking
at).  MouseGrabber.mousePressed calls MouseGrabber.CancelPopupMenu if the
mouse is clicked outside of the menu.  CancelPopupMenu calls
JPopupMenu.firePopupMenuCanceled, which calls popupMenuCanceled on any
listeners.

However, in 1.1, in src/javax/swing/JPopupMenu.java, the MouseGrabber class
no longer exists, and although JPopupMenu.firePopupMenuCancelled still
exists, there is no place in the 1.1 source code where this is ever called.
Hence, popupMenuCanceled never gets called on any listeners.

Let me know if this clarifies the bug sufficiently.  If not, I can put
together some sample code to illustrate the problem.
(Review ID: 56920) 
======================================================================

Comments
WORK AROUND Name: dbT83986 Date: 05/29/99 Catch the popupMenuWillBecomeInvisible event, and write code to figure out whether a menu item was actually selected or not. ======================================================================
11-06-2004