public class KeyBindings
extends java.lang.Object
implements java.awt.event.ActionListener
The action can also be disabled/enabled.
Constructor and Description |
---|
KeyBindings(java.lang.String actionDesc)
Constructs a new KeyBinding.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
Perform all registered actions
|
void |
addActionListener(java.awt.event.ActionListener a)
Add an action listener.
|
void |
addDefaultKeyBinding(javax.swing.KeyStroke prefixStroke,
javax.swing.KeyStroke stroke)
Add a one or two-stroke key binding to the default bindings list
|
void |
addDefaultKeyBinding(KeyStrokePair k)
Add a key stroke pair to the default bindings list
|
void |
addKeyBinding(javax.swing.KeyStroke prefixStroke,
javax.swing.KeyStroke stroke)
Add a one or two-stroke key binding.
|
void |
addKeyBinding(KeyStrokePair k)
Add a key stroke pair
|
void |
addKeyBindings(java.lang.String str)
Add key bindings.
|
java.lang.String |
bindingsToString()
Convert key bindings to a string
|
void |
clearKeyBindings()
Clear all active bindings
|
java.lang.String |
describe() |
java.lang.String |
getActionDesc()
Get the action description that describes this key binding
|
java.util.Iterator |
getActionListeners()
Get an iterator over the actionListeners
|
java.util.Iterator<KeyStrokePair> |
getDefaultKeyStrokePairs()
Get an iterator over the default key stroke pairs
|
boolean |
getEnabled() |
java.util.Iterator<KeyStrokePair> |
getKeyStrokePairs()
Get an iterator over the user key stroke pairs
|
boolean |
getUsingDefaultKeys() |
void |
removeActionListener(java.awt.event.ActionListener a)
Remove an action listener
|
void |
removeKeyBinding(KeyStrokePair k)
Removes a key binding
|
void |
setEnabled(boolean b) |
void |
setEventSource(java.lang.Object source)
Set the object that will used as the "source" when the actions in
this KeyBindings object are activated.
|
void |
setUsingDefaultKeys(boolean b)
Set the value of usingDefaultKeys.
|
public KeyBindings(java.lang.String actionDesc)
actionDesc
- description of the key binding to show to the userpublic void addKeyBinding(javax.swing.KeyStroke prefixStroke, javax.swing.KeyStroke stroke)
prefixStroke
- optional prefix stroke. may be nullstroke
- required strokepublic void addKeyBinding(KeyStrokePair k)
k
- the key stroke pairpublic void addKeyBindings(java.lang.String str)
KeyBindings.sep
.str
- string representing a list of key stroke pairs.public void removeKeyBinding(KeyStrokePair k)
k
- the key stroke pair to removepublic void addDefaultKeyBinding(javax.swing.KeyStroke prefixStroke, javax.swing.KeyStroke stroke)
prefixStroke
- optional prefix stroke. may be nullstroke
- required strokepublic void addDefaultKeyBinding(KeyStrokePair k)
k
- the key stroke pairpublic void clearKeyBindings()
public void addActionListener(java.awt.event.ActionListener a)
a
- the action listener to addpublic void removeActionListener(java.awt.event.ActionListener a)
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
e
- the ActionEventpublic java.lang.String bindingsToString()
public java.lang.String describe()
public java.lang.String getActionDesc()
public java.util.Iterator getActionListeners()
public java.util.Iterator<KeyStrokePair> getKeyStrokePairs()
public java.util.Iterator<KeyStrokePair> getDefaultKeyStrokePairs()
public void setEventSource(java.lang.Object source)
source
- the object to be set as the source of the event passed
to the actionListeners on activation.public void setUsingDefaultKeys(boolean b)
b
- true if using default keys, false otherwisepublic boolean getUsingDefaultKeys()
public void setEnabled(boolean b)
public boolean getEnabled()