Unsure of whether to use key bindings
My app has two text input components, a terminal and a chat window. Right now I'm using key listeners so that whichever component has focus receives key typed events. This works, but it's potentially a little confusing if neither component has focus.
So what I'd like is for the chat window to receive key events when it has focus, and the terminal to receive key events when it or anything else other than the chat window has focus.
Can I do this with key bindings? I've never used them directly (I understand they're used for accelerators and mnemonics and stuff like that) and I'm a little confused about them. Is there an easy way to set up key bindings for "any key", or would I need to create a binding for every key I want my terminal to accept?
Re: Unsure of whether to use key bindings
There are three input maps. Judicious selection (and experimenting) should get you what you want.
Not that I know of.
Is there an easy way to set up key bindings for "any key"
I would use a KeyListener. maybe on the glassPane if I need to capture a keyPressed anywhere in the GUI, although some work might be needed to forward KeyEvents.
or would I need to create a binding for every key I want my terminal to accept?