This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I have a program where a list of certain objects is constructed from a file. A graphical representation of the frist object in the list is drawn inside a JPanel. Now I would like to navigate the list using the keyboard, for instance the up and down arrows, and I am reading up on KeyListener and keybindings. I am a little confused. Is it correct that you use keybindings when you already have some menu/mouse action in place and just want to use keyboard as shortcut while KeyListener is for when you start from bottom like in my case ?
A Key Binding is used when you want to listen for a specific KeyStroke as oppose to any KeyStroke. So listening for up/down/left/right are specific KeyStrokes. If you want to listen for a large group of KeyStroke, say all the letters of the alphabet, then you would probably use a KeyListener rather than writing 26 key bindings.
So, in general you should always use Key Bindings. Swing was designed to use Key Bindings.
Old AWT applications used KeyListeners because Key Bindings didn't exist back then.