Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

creating and firing keyevent from action event on textfield

1001738Apr 9 2013 — edited May 8 2013
My virtual keyboard have buttons to represent keys in keyboard. On button pressed action event is generated. To type some text in text field using virtual key board , changed all action events of each button pressed to key events and doing fireevent on textfield. But no text is seen in textfield. Not understanding what's happening with firevent. When printing keyevent code getting right code.

public void handle(ActionEvent event) {
textField.requestFocus();

KeyEvent keyEvent = KeyEvent.impl_keyEvent(textField, KeyCode.valueOf(name).impl_getChar(), name, KeyCode.valueOf(name).impl_getCode(), false, false, false, false, new EventType<KeyEvent>());

KeyCode code = keyEvent.getCode();
System.out.println("code : " + code);

textField.fireEvent(keyEvent);
keyEvent.consume();

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 5 2013
Added on Apr 9 2013
22 comments
6,014 views