
Convenience method for building an array of
KeyBindings. While this method is not deprecated, developers
should instead use
ActionMap and
InputMap for
supplying key bindings.
This method returns an array of KeyBindings, one for each
alternating key-action pair in keyBindingList.
A key can either be a String in the format
specified by the KeyStroke.getKeyStroke method, or
a KeyStroke. The action part of the pair is a
String that corresponds to the name of the Action.
The following example illustrates creating a KeyBinding array
from six alternating key-action pairs:
JTextComponent.KeyBinding[] multilineBindings = makeKeyBindings( new Object[] {
"UP", DefaultEditorKit.upAction,
"DOWN", DefaultEditorKit.downAction,
"PAGE_UP", DefaultEditorKit.pageUpAction,
"PAGE_DOWN", DefaultEditorKit.pageDownAction,
"ENTER", DefaultEditorKit.insertBreakAction,
"TAB", DefaultEditorKit.insertTabAction
});
If
keyBindingList's length is odd, the last element is
ignored.
Supplying a null value for either the key or
action part of the key-action pair results in
creating a KeyBinding with the corresponding value
null. As other parts of Swing's expect non-null values
in a KeyBinding, you should avoid supplying null as
either the key or action part of the key-action
pair.
Returns:
an array of {@code KeyBindings}
Parameters:
- keyBindingList - an array of {@code key-action} pairs
Throws:
- NullPointerException - if {@code keyBindingList} is {@code null}
- ClassCastException - if the {@code key} part of the pair is
not a {@code KeyStroke} or {@code String}, or the
{@code action} part of the pair is not a {@code String}
See Also:
ActionMap,
InputMap,
KeyStroke.getKeyStroke(char),