chooser
Class BindingAdaptor

java.lang.Object
  extended by java.awt.event.KeyAdapter
      extended by chooser.BindingAdaptor
All Implemented Interfaces:
KeyListener, EventListener

public class BindingAdaptor
extends KeyAdapter

Adaptor that uses keyboard input to set the selected shortcut field of a BindingChooser. This can be added to focused components to provide editing functionality for this chooser. This prevents duplicate entries and varies how it captures input according to the type of key event its set to capture.

Version:
August 19, 2007
Author:
Damian Johnson (atagar1@gmail.com)

Method Summary
 int getDisablingKeyCode()
          Provides the keycode that can be input to generated key adaptors to disable key bindings.
 int getInputEventType()
          Provides the type of keystroke registered by input via generated key adaptors.
 boolean isBindingDisablingEnabled()
          Provides if bindings are currently disableable via generated key adaptors or not.
 void keyPressed(KeyEvent event)
           
 void keyReleased(KeyEvent event)
           
 void keyTyped(KeyEvent event)
           
 void setBindingsDisableable(boolean enable)
          Sets if bindings can be disabled via generated key adaptors with the disabling key code.
 void setDisablingKeyCode(int keycode)
          Sets the keycode used to disable individual key bindings (removing it from returned mappings) via generated key adaptors.
 void setInputEventType(int type)
          Sets the type of keystroke registered by input via generated key adaptors (by default KeyEvent.KEY_PRESSED).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isBindingDisablingEnabled

public boolean isBindingDisablingEnabled()
Provides if bindings are currently disableable via generated key adaptors or not.

Returns:
true if input can disable bindings, false otherwise.

setBindingsDisableable

public void setBindingsDisableable(boolean enable)
Sets if bindings can be disabled via generated key adaptors with the disabling key code. By default this is false.

Parameters:
enable - if true then input can disable bindings, otherwise bindings may not be disabled

getDisablingKeyCode

public int getDisablingKeyCode()
Provides the keycode that can be input to generated key adaptors to disable key bindings.

Returns:
keycode of disabling input

setDisablingKeyCode

public void setDisablingKeyCode(int keycode)
Sets the keycode used to disable individual key bindings (removing it from returned mappings) via generated key adaptors. This only works if the set event type is KEY_PRESSED or KEY_RELEASED since KEY_TYPED events fail to provide keycodes. By default this is VK_ESCAPE.

Parameters:
keycode - keycode that sets selected entry to a disabled state

getInputEventType

public int getInputEventType()
Provides the type of keystroke registered by input via generated key adaptors.

Returns:
type of input detected by generated key adaptors

setInputEventType

public void setInputEventType(int type)
Sets the type of keystroke registered by input via generated key adaptors (by default KeyEvent.KEY_PRESSED). This must be a valid type of key event which includes: KEY_PRESSED, KEY_RELEASED, or KEY_TYPED.

Parameters:
type - type of keystroke registered by input
Throws:
IllegalArgumentExeption - if type doesn't match a valid key event

keyPressed

public void keyPressed(KeyEvent event)
Specified by:
keyPressed in interface KeyListener
Overrides:
keyPressed in class KeyAdapter

keyReleased

public void keyReleased(KeyEvent event)
Specified by:
keyReleased in interface KeyListener
Overrides:
keyReleased in class KeyAdapter

keyTyped

public void keyTyped(KeyEvent event)
Specified by:
keyTyped in interface KeyListener
Overrides:
keyTyped in class KeyAdapter