pfarwell schrieb:
>
> What are the relative advantages or disadvantages of using
> JComponent registerKeyboardAction() versus Component
> addKeyListener()? (According to the javadocs
> registerKeyboardAction() has been replaced by getInputMap().put
> () and getActionMap().put() - but as far as I can tell these are
> functionally equivalent to registerKeyboardAction).
They are different: KeyListeners are near to lowest level processing,
disadvantage is that you have to do a lot of work yourself, advantage is
that listeners are the first in line to see the events. Note that you
they get only events from focused components.
Actions associated with keyStrokes are higher level, and as such easier
to handle. You just have to define the state of the keystroke that
should trigger some action, then the system does all the bookkeeping for
you. Disadvantage might be that keybindings are the last in line to see
the events. Advantage is handling of keystrokes in Components even if
they are not focused.
On the whole I nearly never use KeyListeners but very often use
KeyBindings.
There is a very good article at the swing connection from Jan: Keyboard
Bindings in Swing. It's more about differences between the old
registerkeyboardAction vs. the new inputMap/actionMap but I found it
extremely interesting.
Greetings
Jeanette
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing