dcsimg
KeyEventDispatcher Receiving Excessive Number Of Keypresses
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Scott_Widgum
Posted On:   Monday, December 9, 2002 11:44 AM

Greetings, I have a Swing/AWT drawing application (running on OS X) that has a label option. When the user selects the label option, they are allowed to click once on my canvas panel (which resides in an internal frame in a desktop pane) and then type their text. My label class that implements the KeyEventDispatcher correctly gains access to the keyboard input stream through: DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(this); and performs work upon the key events through the dispatchKeyEvent function. The problem is that when the user types their text, multiple keypresses are received for only one keystroke. Sometimes 6 of the same c   More>>

Greetings,


I have a Swing/AWT drawing application (running on OS X) that has a label option. When the user selects the label option, they are allowed to click once on my canvas panel (which resides in an internal frame in a desktop pane) and then type their text. My label class that implements the KeyEventDispatcher correctly gains access to the keyboard input stream through:



DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(this);



and performs work upon the key events through the dispatchKeyEvent function.



The problem is that when the user types their text, multiple keypresses are received for only one keystroke. Sometimes 6 of the same character are captured, sometimes 3. The keycode for the character, even though it remains the same, can sometimes change. The following is a capture of a user typing "Greetings, this is a test!!!". I have captured the result of each event's getID(), getWhen(), hashCode(), getKeyChar(), and getKeyCode() and copied the output below. As you can see, this is quite wacky behavior. I have totally removed my keyListener, since the focus subsystem was changed. I thought perhaps multiple listerners were picking up the same keypress, but that would not explain two identical keyChars with different keyCodes? I am running the application on Mac OS X. A plethora of thanks in advance for any morsel of assistance.






ID: 401 When: 4711705034502649969 Hash: 13285460 : Capturing keypress - ? - 16


ID: 401 When: 4711705043532228152 Hash: 11958058 : Capturing keypress - G - 71


ID: 400 When: 4711705043532228152 Hash: 4400085 : Capturing keypress - G - 0


ID: 402 When: 4711705046111624448 Hash: 13842387 : Capturing keypress - G - 71


ID: 402 When: 4711705048995974160 Hash: 3482471 : Capturing keypress - ? - 16


ID: 401 When: 4711705078944770377 Hash: 6835750 : Capturing keypress - r - 82


ID: 400 When: 4711705078944770377 Hash: 15961328 : Capturing keypress - r - 0


ID: 402 When: 4711705082492273778 Hash: 6372179 : Capturing keypress - r - 82


ID: 401 When: 4711705089250275969 Hash: 10754076 : Capturing keypress - e - 69


ID: 400 When: 4711705089250275969 Hash: 4113117 : Capturing keypress - e - 0


ID: 402 When: 4711705091518985069 Hash: 3289716 : Capturing keypress - e - 69


ID: 401 When: 4711705095060432565 Hash: 10498262 : Capturing keypress - e - 69


ID: 400 When: 4711705095060432565 Hash: 15002459 : Capturing keypress - e - 0


ID: 402 When: 4711705097629585365 Hash: 10740767 : Capturing keypress - e - 69


ID: 401 When: 4711705100858348505 Hash: 15796839 : Capturing keypress - t - 84


ID: 400 When: 4711705100858348505 Hash: 1704781 : Capturing keypress - t - 0


ID: 402 When: 4711705103747368994 Hash: 13010541 : Capturing keypress - t - 84


ID: 401 When: 4711705105032219198 Hash: 14365489 : Capturing keypress - i - 73


ID: 400 When: 4711705105032219198 Hash: 12751864 : Capturing keypress - i - 0


ID: 402 When: 4711705107618573341 Hash: 11777702 : Capturing keypress - i - 73


ID: 401 When: 4711705110821083493 Hash: 12303100 : Capturing keypress - n - 78


ID: 400 When: 4711705110821083493 Hash: 10194937 : Capturing keypress - n - 0


ID: 401 When: 4711705113398804752 Hash: 14741677 : Capturing keypress - g - 71


ID: 400 When: 4711705113398804752 Hash: 13592111 : Capturing keypress - g - 0


ID: 402 When: 4711705114381471795 Hash: 11026476 : Capturing keypress - n - 78


ID: 402 When: 4711705116308247812 Hash: 1134930 : Capturing keypress - g - 71


ID: 401 When: 4711705120172816434 Hash: 11339833 : Capturing keypress - s - 83


ID: 400 When: 4711705120172816434 Hash: 7806641 : Capturing keypress - s - 0


ID: 402 When: 4711705123400903117 Hash: 4567087 : Capturing keypress - s - 83


ID: 401 When: 4711705125972375198 Hash: 6649557 : Capturing keypress - , - 44


ID: 400 When: 4711705125972375198 Hash: 14418506 : Capturing keypress - , - 0


ID: 402 When: 4711705129178686397 Hash: 11604935 : Capturing keypress - , - 44


ID: 401 When: 4711705131433093256 Hash: 13969258 : Capturing keypress - - 32


ID: 400 When: 4711705131433093256 Hash: 1690810 : Capturing keypress - - 0


ID: 402 When: 4711705134027049491 Hash: 6559246 : Capturing keypress - - 32


ID: 401 When: 4711705137234584755 Hash: 2180223 : Capturing keypress - t - 84


ID: 400 When: 4711705137234584755 Hash: 9052195 : Capturing keypress - t - 0


ID: 402 When: 4711705139823483667 Hash: 2704300 : Capturing keypress - t - 84


ID: 401 When: 4711705140446951857 Hash: 3614661 : Capturing keypress - h - 72


ID: 400 When: 4711705140446951857 Hash: 14279289 : Capturing keypress - h - 0


ID: 401 When: 4711705144633675240 Hash: 10526273 : Capturing keypress - i - 73


ID: 400 When: 4711705144633675240 Hash: 3610207 : Capturing keypress - i - 0


ID: 402 When: 4711705145287133039 Hash: 8820986 : Capturing keypress - h - 72


ID: 402 When: 4711705148187137907 Hash: 15712776 : Capturing keypress - i - 73


ID: 401 When: 4711705178769645812 Hash: 11067315 : Capturing keypress - s - 83


ID: 400 When: 4711705178769645812 Hash: 15607307 : Capturing keypress - s - 0


ID: 402 When: 4711705182000985932 Hash: 16754411 : Capturing keypress - s - 83


ID: 401 When: 4711705190361096824 Hash: 1913382 : Capturing keypress - - 32


ID: 400 When: 4711705190361096824 Hash: 5584739 : Capturing keypress - - 0


ID: 402 When: 4711705194230014101 Hash: 3980107 : Capturing keypress - - 32


ID: 401 When: 4711705198091780258 Hash: 272782 : Capturing keypress - i - 73


ID: 400 When: 4711705198091780258 Hash: 12104635 : Capturing keypress - i - 0


ID: 402 When: 4711705201643535677 Hash: 1690651 : Capturing keypress - i - 73


ID: 401 When: 4711705204212076443 Hash: 10626673 : Capturing keypress - s - 83


ID: 400 When: 4711705204212076443 Hash: 949406 : Capturing keypress - s - 0


ID: 402 When: 4711705206480012449 Hash: 1646156 : Capturing keypress - s - 83


ID: 401 When: 4711705208396802666 Hash: 10625254 : Capturing keypress - - 32


ID: 400 When: 4711705208396802666 Hash: 13829853 : Capturing keypress - - 0


ID: 402 When: 4711705211621217152 Hash: 3096997 : Capturing keypress - - 32


ID: 401 When: 4711705215168978249 Hash: 403357 : Capturing keypress - a - 65


ID: 400 When: 4711705215168978249 Hash: 9015524 : Capturing keypress - a - 0


ID: 402 When: 4711705216457597287 Hash: 12469859 : Capturing keypress - a - 65


ID: 401 When: 4711705218057032371 Hash: 4466342 : Capturing keypress - - 32


ID: 400 When: 4711705218057032371 Hash: 14197152 : Capturing keypress - - 0


ID: 402 When: 4711705222251390058 Hash: 5408640 : Capturing keypress - - 32


ID: 401 When: 4711705224505442582 Hash: 5520561 : Capturing keypress - t - 84


ID: 400 When: 4711705224505442582 Hash: 10564408 : Capturing keypress - t - 0


ID: 402 When: 4711705230639428974 Hash: 5068142 : Capturing keypress - t - 84


ID: 401 When: 4711705245772263059 Hash: 13506038 : Capturing keypress - e - 69


ID: 400 When: 4711705245772263059 Hash: 12662230 : Capturing keypress - e - 0


ID: 402 When: 4711705248019293311 Hash: 5443901 : Capturing keypress - e - 69


ID: 401 When: 4711705252537996190 Hash: 949587 : Capturing keypress - s - 83


ID: 400 When: 4711705252537996190 Hash: 3534544 : Capturing keypress - s - 0


ID: 402 When: 4711705257027514768 Hash: 16000817 : Capturing keypress - s - 83


ID: 401 When: 4711705259938697288 Hash: 12309474 : Capturing keypress - t - 84


ID: 400 When: 4711705259938697288 Hash: 3120077 : Capturing keypress - t - 0


ID: 402 When: 4711705262828845206 Hash: 14344544 : Capturing keypress - t - 84


ID: 401 When: 4711705274110446540 Hash: 14662467 : Capturing keypress - ? - 16


ID: 401 When: 4711705285696421468 Hash: 1973183 : Capturing keypress - ! - 49


ID: 400 When: 4711705285696421468 Hash: 9826960 : Capturing keypress - ! - 0


ID: 402 When: 4711705288924798061 Hash: 7714809 : Capturing keypress - ! - 49


ID: 401 When: 4711705293100150518 Hash: 16772849 : Capturing keypress - ! - 49


ID: 400 When: 4711705293100150518 Hash: 713167 : Capturing keypress - ! - 0


ID: 402 When: 4711705295028021751 Hash: 4845633 : Capturing keypress - ! - 49


ID: 401 When: 4711705299222927046 Hash: 9980573 : Capturing keypress - ! - 49


ID: 400 When: 4711705299222927046 Hash: 3916193 : Capturing keypress - ! - 0


ID: 402 When: 4711705300509516712 Hash: 914658 : Capturing keypress - ! - 49


ID: 402 When: 4711705311779360573 Hash: 13999420 : Capturing keypress - ? - 16


- 1001 When: 4711705324982906085 Hash: 15206241 : Capturing keypress -

   <<Less
About | Sitemap | Contact