JDK-4912806 : 1.5.0 Regression: Showing JPopupMenu prevents double clicking on JButton
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0,1.4.1,1.4.2,5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS:
    linux,solaris_9,windows_98,windows_nt,windows_2000,windows_xp linux,solaris_9,windows_98,windows_nt,windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2003-08-26
  • Updated: 2003-10-18
  • Resolved: 2003-10-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 b25Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
What follows is a description of what I beleive the problem to be. See note at the bottom on how this is creating problems with internal frames in the Motif look and feel.

A JButton is set up to show a JPopupMenu when it is clicked (on ActionPerformed). The button also has a MouseListener that listens for mousePressed events. It checks these mouse events for the click count and takes action when the click count is 2 (In the example, no action is taken, the demo simply prints out the click count). In 1.5.0, it seems that showing the popup menu prevents the click count from getting to 2.

To reproduce, compile and run the attached demo.
Double click on the button.

In 1.4.2, one can easily double click on the button and get a click count of 2 printed to the console.

In 1.5.0, one can no longer double click to get a click count of 2.

This is on Windows NT 4, SP 6.

------

Note, the attached demo is a simple test case showing the problem. It was first discovered with internal frames in the Motif look and feel. In 1.5.0, double clicking on the system button (upper left) fails to close an internal frame. When an internal frame is iconified, double clicking on that icon also fails to restore the internal frame. This can be seen in the SwingSet2 demo.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger tiger-beta FIXED IN: tiger tiger-beta INTEGRATED IN: tiger-b25 tiger-beta
24-08-2004

SUGGESTED FIX ------- BasicLookAndFeel.java ------- *** /tmp/sccs.aoa4Fo Fri Aug 29 22:13:40 2003 --- BasicLookAndFeel.java Fri Aug 29 16:13:27 2003 *************** *** 955,960 **** --- 955,961 ---- "RIGHT", "selectParent", "KP_RIGHT", "selectParent", }, + "PopupMenu.consumeEventOnClose", Boolean.FALSE, // *** OptionPane // You can additionaly define OptionPane.messageFont which will ------- BasicPopupMenuUI.java ------- *** /tmp/sccs.gQaO3k Fri Aug 29 22:13:13 2003 --- BasicPopupMenuUI.java Fri Aug 29 21:47:04 2003 *************** *** 731,738 **** // If this property is set to TRUE component wants // to deal with this event by himself. cancelPopupMenu(); // Consume the event so that normal processing stops. ! if(!(src instanceof MenuElement)) { ((MouseEvent)ev).consume(); } } --- 731,742 ---- // If this property is set to TRUE component wants // to deal with this event by himself. cancelPopupMenu(); + // Ask UIManager about should we consume event that closes + // popup. This made to match native apps behaviour. + boolean consumeEvent = + UIManager.getBoolean("PopupMenu.consumeEventOnClose"); // Consume the event so that normal processing stops. ! if(consumeEvent && !(src instanceof MenuElement)) { ((MouseEvent)ev).consume(); } } ------- GTKLookAndFeel.java ------- *** /tmp/sccs.QMai6o Fri Aug 29 22:14:18 2003 --- GTKLookAndFeel.java Fri Aug 29 16:20:15 2003 *************** *** 153,158 **** --- 153,159 ---- table.put("TitledBorder.border", new UIDefaults.ProxyLazyValue( "javax.swing.plaf.BorderUIResource", "getEtchedBorderUIResource")); + table.put("PopupMenu.consumeEventOnClose", Boolean.TRUE); return table; } ------- MotifLookAndFeel.java ------- *** /tmp/sccs.Hcaadp Fri Aug 29 22:14:44 2003 --- MotifLookAndFeel.java Fri Aug 29 21:22:33 2003 *************** *** 617,622 **** --- 617,623 ---- "PopupMenu.border", popupMenuBorder, "PopupMenu.foreground", table.get("menuText"), "PopupMenu.font", dialogPlain12, + "PopupMenu.consumeEventOnClose", Boolean.TRUE, "Label.font", dialogPlain12, "Label.background", table.get("control"),
24-08-2004

EVALUATION This is regression that made by refactoring of the mouse event handler in the popup menu. The idea of suggested fix is to make the LAF property that will say should the popup consume the event that closes it or not depending on the LAF that currently installed. ###@###.### 2003-09-21
21-09-2003