Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trapping ESC from a dialog

Status
Not open for further replies.

lesneskp

Programmer
Jul 3, 2002
19
US
Hello all,

My application catches ESCAPE keypresses and closes the current internal frame in such a situation.

Dialogs (as popped up from JOptionPane) are problematic in that I have not been able to catch the ESCAPE event in the dialog, and it ends up propagating to the internal frame, thus both the dialog and the internal frame are closed.

I have tried creating a JOptionPane instance (as opposed to using its convenience methods) and getting a dialog from it with createDialog(), and adding a key listener to the dialog catches most keypresses EXCEPT escape!!!! Not fair!!!! How can I get that event and consume it in the dialog???
 
NO! I spoke too soon. Registering a keyboard action (not listener, sorry) traps ESC so I can do something else and keep the dialog open, but if I try to manually dispose the dialog in the event handler, the old behavior comes back -- the event is propagated, despite numerous calls to consume() the event. This is bordering on rediculous....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top