United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6895894 On IE7, JButton is disarmed when pressed while other window is active
JDK-6895894 : On IE7, JButton is disarmed when pressed while other window is active

Details
Type:
Bug
Submit Date:
2009-10-28
Status:
Resolved
Updated Date:
2010-12-15
Project Name:
JDK
Resolved Date:
2009-12-23
Component:
deploy
OS:
windows_vista
Sub-Component:
plugin
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0u17
Fixed Versions:
5.0u23-rev (b02)

Related Reports
Backport:
Backport:
Backport:
Backport:
Backport:
Backport:
Relates:

Sub Tasks

Description
Vista SP2, IE7, 1.5.0_17

A JButton on an applet running in IE7 does not invoke action intermittently if other window
is active. 

With a simple applet, I can duplicate symptom.  If I count the # of actionPerformed() call count,
sometimes JButton click is not counted if I activate other window, e.g. explorer before the
click.

This does not happen with FireFox, Safari or Chrome browser.

On IE, it looks like focusLost() is called in such case and the button becomes disarmed state.

                                    

Comments
EVALUATION

The problem is because of interaction between java.awt.event.FocusEvent (FOCUS_GAINED and FOCUS_LOST) processing
and java.awt.event.MouseEvent (MOUSE_PRESSED and MOUSE_RELEASED) processing.
To process MouseEvent event dispatching thread (EDT) uses
javax.swing.plaf.basic.BasicButtonListener.mousePressed() 
and
javax.swing.plaf.basic.BasicButtonListener.mouseReleased() 

To process FocusEvent EDT uses
javax.swing.plaf.basic.BasicButtonListener.focusLost() 
and
javax.swing.plaf.basic.BasicButtonListener.focusGained() 

When FocusEvent is processed after MOUSE_PRESSED but before MOUSE_RELEASED
it depresses and disarms buttons so MOUSE_RELEASED event processing
doesn't recognize pressed buttons and as a result actionPerformed() doesn't get executed.
                                     
2009-11-19
SUGGESTED FIX

Since this is a temporary fix which corrects a result rather than a real root cause we decided to introduce a secret switch to trigger the fix with Java runtime parameter:
-Dfix6895894=true

The fix doesn't allow 
javax.swing.plaf.basic.BasicButtonListener.focusLost()
to run:

 ButtonModel model = b.getModel();
 model.setArmed(false);
 model.setPressed(false); 

when mouse button is still pressed.

webrev:
http://jpsesvr.sfbay.sun.com:8080/ctetools/html/ViewDetail.jsp?index=3267
                                     
2009-12-21
SUGGESTED FIX

Also a fix for CR 6711682 can be considered as a fix for this bug.
However this fix causes a side effect/regression.
See CR (will be filled soon)
                                     
2010-06-15



Hardware and Software, Engineered to Work Together