Check out Global Event Listeners which gives you a couple of choices:
- Use an
AWTEventListener
. - Us a
KeyEventPostProcessor
.
Question
I need that all the key events (including Carriage Return, TAB, etc) generated by all child or grandchildren components of a JFrame, to be listened for a single method inside this JFrame. I have googled a lot, but I have not been able to find the solution I need. I found a partial solution using "InputMap/ActionMap", but it only allows to add particular KeyStrokes on the InputMap, but I need all possible Key Strokes to be forwarded to the parent JFrame.
Thanks.
(I saw this thread, but I was expecting a solution within the Swing API, specifically to address this subject.
Solution
Check out Global Event Listeners which gives you a couple of choices:
AWTEventListener
.KeyEventPostProcessor
.