im doing a simple animation and it's bound to display a series of images when the arrow keys on the NUM pad are pressed. There shouln't be any problem abou this, but arrarently I don't even get the KeyEvents I hoped to process with my KeyAdapter:
I'd appreciate any suggestion about what I'm doing wrong here.
Thanks in advance,
The man who sets out to carry a cat by its tail learns something that will always be useful and which never will grow dim or doubtful.
-- Mark Twain
I think adding keybindings instead of keylisteners in the above case won't make any difference as key listeners are notified before key bindings: The flow is like this(for JComponents): 1) key listeners 2) processComponentKeyEvent(), if the componenet overrides it 3) processKeyBindings..finally
So I think, from a design point of view, the user should actuall override processComponentKeyEvent() instead, as the given key behaviour of the componnet is tightly bound to how the component should be...just a feeling actually
I guess there are couple of design issues in this classic software the GOD coded.
Key bindings provide a high-level, loosely-coupled way to program keyboard input; they should always be the first tool the Swing programmer reaches for. Overriding processComponentKeyEvent(), on the other hand, is very low-level and tightly-coupled, and should only be done as a last resort, in my opinion.