tags:

views:

26

answers:

2

This one is pretty crazy:

I've got an AppSight recording (for those not familiar, it's a recording of what they did including keyboard/mouse input + network traffic, etc) of a customer reproducing a bug. Basically, we've got a series of items listed on the screen with JCheckBox-es down the left side. We've got a MouseListener set for the JPanel that looks something like this:

private MouseAdapter createMouseListener() {
    return new MouseAdapter(){
        public void mousePressed( MouseEvent e ) {

            if( e.getComponent() instanceof JCheckBox ) {
                // Do stuff
            }
        }
    };
}

Based on the recording, it appears very strongly that they click just above one of the checkboxes. After that, it's my belief that this listener fired and the "Do stuff" block happened. However, it did NOT check the box. The user then saw that the box was unchecked, so they clicked on it. This caused the "Do stuff" block to fire again, thus undoing what it had done the first time. This time, the box was checked. Therefore, the user thinks that the box is checked, and it looks like it is, but our client thinks that the box is unchecked as it was clicked twice.

Is this possible at all? For the life of me, I can't reproduce it or see how it could be possible, but based on the recording and the data the client sent to the server, I can't see any other logical explanation.

Any help, thoughts, and or ideas would be much appreciated.

+2  A: 

Maybe the user clicked on the checkbox, but before release the mouse button, he moved the mouse away from the component. I'm pretty sure the chechbox won't get checked in this case, although not so sure about the Event Thread behaviour under this scenario.

Federico Cristina
As soon as I read this answer I knew it was right. Pulled open the application and duplicated first try. Thanks for the help!
Morinar
I'm Glad I could help! :)
Federico Cristina
+1  A: 

I don't think you can assume that because the mouse was pressed on the checkbox that it will be also released on the checkbox. Maybe just do something like this:

private MouseAdapter createMouseListener() { 
    return new MouseAdapter(){ 
        public void mouseReleased( MouseEvent e ) { 

            if( e.getComponent() instanceof JCheckBox ) { 
                // And just to be sure....
                JCheckBox jcb = (JCheckBox) e.getComponent();
                if(jcb.isSelected())
                {
                    // Do stuff  
                }
            } 
        } 
    }; 
} 
Catchwa