JDK-4999383 : REG: on win32 Checkbox configured OFF is inappropriately automatically turned on
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-02-23
  • Updated: 2006-04-05
  • Resolved: 2006-04-05
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.
JDK 6
6 b79Fixed
Related Reports
Relates :  
Description
Name: gm110360			Date: 02/23/2004


FULL PRODUCT VERSION :
java version "1.4.1_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_05-b01)
Java HotSpot(TM) Client VM (build 1.4.1_05-b01, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
The Checkbox in later Java releases (worked fine in earlier Java) can be incorrectly activated by only the mouse up events (where the mouse down events were from another Window).

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached sample program.

You can clearly see what is happening, if on the double click, you hold the mouse button down and do not release until a couple of seconds later.

Regression: worked in 1.3

You have a bug in your web form.  In the 'Regression' field, all I could see is "Java 2 SDK, Standard E" for all lines.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When you see the checkbox, it should be OFF, as the code has configured.
ACTUAL -
When you see the checkbox, it is incorrectly turned on.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
public class CheckboxBug extends Frame {
    public static void main( String args[] ) {
        new CheckboxBug(0);
        }
    public CheckboxBug(int level) {
        if (level==0) {
            List list = new List();
            list.addItem("Double click me");
            add("Center",list);
            }
        else if (level==1) {
            add("Center",new Checkbox("I am OFF",false));
            }
        move(100,100);
        resize(400,300);
        show();
        }
    public boolean action( Event evt, Object what ) {
        if (evt.target instanceof List) {
            new CheckboxBug(1);
            }
        return true;
        }
    }

---------- END SOURCE ----------

Release Regression From : 1.3.1
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

(Incident Review ID: 240011) 
======================================================================
###@###.### 10/6/04 15:03 GMT

Comments
SUGGESTED FIX --- WS.mustang_test_choice 2006-02-27 12:02:18.000000000 +0300 --- awt_Checkbox.cpp 2006-02-27 12:02:18.000000000 +0300 *************** *** 143,155 **** RECT rect; ::GetClientRect(GetHWnd(), &rect); ! if (::PtInRect(&rect, p) && button == LEFT_BUTTON) { WmNotify(BN_CLICKED); } ! return mrResult; } MsgRouting AwtCheckbox::WmNotify(UINT notifyCode) { --- 143,162 ---- RECT rect; ::GetClientRect(GetHWnd(), &rect); ! if (::PtInRect(&rect, p) && button == LEFT_BUTTON && m_fLButtonDowned) { WmNotify(BN_CLICKED); } ! m_fLButtonDowned = FALSE; return mrResult; } + MsgRouting + AwtCheckbox::WmMouseDown(UINT flags, int x, int y, int button) + { + m_fLButtonDowned = TRUE; + return AwtComponent::WmMouseDown(flags, x, y, button); + } + MsgRouting AwtCheckbox::WmNotify(UINT notifyCode) {
27-02-2006

EVALUATION At first I verifyed that it doesn't depend on event handling model. But anyway test shouldn't use old-styled event scheme. Instead, use listener model. See my sample in Comments. To fix it I'd use already existing var m_fLButtonDowned to track if mouse being pressed under checkbox or not. Depending on it we will change checkbox's state.
27-02-2006

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang
17-09-2004

EVALUATION Name: atR10251 Date: 02/24/2004 In awt_Checkbox.cpp of 1.43 version WmMouseApp handler was added and there was no checking where BUTTONDOWN event occurs. This causes the behaviour described in the testcase. I doubt whether this problem can be reproduced in a real app. And the problem itself doesn't look so serious. So, I think there's no urgent need to fix it in tiger. ###@###.### 2004-02-24 ====================================================================== ###@###.### 10/6/04 15:03 GMT
24-02-2004