MouseListener fired without checking JCheckBox

Posted by Morinar on Stack Overflow See other posts from Stack Overflow or by Morinar
Published on 2010-06-16T22:37:49Z Indexed on 2010/06/16 22:42 UTC
Read the original article Hit count: 207

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about java

Related posts about swing