EVALUATION
The problem is that the BasicPopupMenuUI doens't call JPopupMenu.firePopupMenuCancelled. Previously, the cancelPopupMenu() code and logic to cancel the Popup was in JPopupMenu but was moved into BasicPopupMenuUI. Since firePopupMenuCancelled() is protected, BasicPopupMenuUI has no way of calling this method thereby sending out the popupMenuCancelled() notification.
The solution is to make the firePopupMenuCancelled() method public or add a public or package private method which will call the protected firePopupMenuCancelled() method.
mark.davidson@Eng 2000-03-14
This looks trickier than I thought. The code was refactored so that the MouseGrabber was taken out of JPopupMenu and put into BasicPopupMenuUI. The MouseGrabber.cancelPopupMenu() method should call the JPopupMenu.firePopupMenuCancelled(). This should be done after the statement lastGrapped==getFirstPopup. I'm not too keen on this since it looks a bit messy and I'll have to change firePopupMenuCanceled() from protected to public - which is inconsistent with the other JPopupMenu methods. Still thinking about it.
mark.davidson@Eng 2000-03-28
I tried to add the firePopupMenuCancelled() call in MouseGrabber.cancelPopupMenu() and found that it worked with the current code. However, it's still a hack and not very resiliant to change in complementary classes. It NPE'd when I was refactoring JComboBox. I'm going to abandon this tack and a more drastic change should be thought out. Pehaps with the instroduction of a new interface.
mark.davidson@Eng 2000-04-03
Now that 1.4 and 1.4.1 are out the door and stable, I revisited making JPopupMenu.firePopupMenuCanceled() public and called from the MouseGrabber and the CancelAction (ESCAPE key). This seems to work correctly. The semantics should be that the PopupMenuCanceled event should be before the PopupMenuWillBecomeInvisible event. Also, should ensure that the JComboBox also sends the canceled event when the ESCAPE key is pressed. The diffs are in the suggested fix section.
Unfortunately, we cannot make an API change until 1.5 so I'm going to try another approach by using a client property.
###@###.### 2002-09-04