How do you grab keystrokes in a Java window no matter which control has the focus?

KingNothing

Diamond Member
Apr 6, 2002
7,141
1
0
In Visual Basic, forms had a Key Preview property. When that was true, any keystroke pressed while the form had the focus, regardless of which control had the focus, would be processed by the form's Key events first.

Is there something similar in Java? Only way I can figure out how to do it is to add a KeyListener to every component of the form, which seems clunky.