United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7125491 [macosx] Regression: A component can get unexpected keyTyped event.
JDK-7125491 : [macosx] Regression: A component can get unexpected keyTyped event.

Details
Type:
Bug
Submit Date:
2011-12-28
Status:
Closed
Updated Date:
2012-05-17
Project Name:
JDK
Resolved Date:
2012-02-29
Component:
client-libs
OS:
os_x
Sub-Component:
java.awt
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
7u4 (b11)

Related Reports
Relates:

Sub Tasks

Description
Run a regression test java/awt/KeyboardFocusManager/TypeAhead/ButtonActionKeyTest several times. You will see that there always is action performed. In addition, the next text field does receive some parts of this action entourage: always KEY_RELEASED and sometimes KEY_TYPED but never KEY_PRESSED. The arrival of KEY_TYPED is a regression from 6396785.
For me, KEY_TYPED arrives once of four or five times.

Someway reduced test without Robot or synchronization behaves just the same so that's not a Robot issue.

                                    

Comments
EVALUATION

Here's what happens:

1. "A" key is pressed on the button.

    KEY_PRESSED event is posted (natively originated) with some t0 time.
    KEY_TYPED event is posted (synthesized) with some t1 time.

2. KEY_PRESSED is dispatched to the button, action binding is resolved, focus is requested to the textfield.

    The focus request is marked with a time stamp corresponding to the most-recent-event-time
    (most recently dispatched event) which is t0. A type-ahead-marker (t0) is created & pushed.

3. KEY_TYPED is being dispatched. In case t1 > t0, the event is queued until the textfield gains focus
   and after that is eventually dispatched to the textfield. In case t1 == t0, the event is dispatched
   to the button (expected behaviour).

So, the problem is that t1 and t0 times may differ. However, KEY_PRESSED & KEY_TYPED java events are
actually a production of a single native key down event. So, t1 must equal t0. That's what we have in
X11 code, where KEY_TYPED is also synthesized (not natively originated).
                                     
2012-01-18
SUGGESTED FIX

http://cr.openjdk.java.net/~ant/7125491/webrev.0/
                                     
2012-01-20



Hardware and Software, Engineered to Work Together