com.google.code.validationframework.swing.trigger
Class BaseComponentKeyTrigger<C extends Component>

java.lang.Object
  extended by com.google.code.validationframework.base.trigger.AbstractTrigger
      extended by com.google.code.validationframework.swing.trigger.BaseComponentKeyTrigger<C>
All Implemented Interfaces:
com.google.code.validationframework.api.common.Disposable, com.google.code.validationframework.api.trigger.Trigger

public class BaseComponentKeyTrigger<C extends Component>
extends com.google.code.validationframework.base.trigger.AbstractTrigger
implements com.google.code.validationframework.api.common.Disposable

Trigger that initiates the validation whenever a key is pressed, released or typed on the component.

See Also:
AbstractTrigger, Disposable

Field Summary
protected  C source
          Text component that is the source of the trigger.
 
Fields inherited from class com.google.code.validationframework.base.trigger.AbstractTrigger
listeners
 
Constructor Summary
BaseComponentKeyTrigger(C source, int... keyCodes)
          Constructor specifying the text component to listen to.
 
Method Summary
 void addKey(int keyCode)
          Adds a key code for which the validation will be triggered.
Key codes correspond to KeyEvent#VK_*.
 void dispose()
           
 C getComponent()
          Gets the source component.
 int getKeyEventId()
           
 Collection<Integer> getKeys()
          Gets the key codes for which the validation will be triggered.
Key codes correspond to KeyEvent#VK_*.
 int getModifiers()
           
 void removeKey(int keyCode)
          Removes a key code for which the validation should no longer be triggered.
Key codes correspond to KeyEvent#VK_*.
 void setKeyEventId(int keyEventId)
           
 void setModifiers(int modifiersMask)
           
 void setModifiers(int modifiersMask, boolean strictModifiersMatch)
           
 
Methods inherited from class com.google.code.validationframework.base.trigger.AbstractTrigger
addTriggerListener, fireTriggerEvent, removeTriggerListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

source

protected C extends Component source
Text component that is the source of the trigger.

Constructor Detail

BaseComponentKeyTrigger

public BaseComponentKeyTrigger(C source,
                               int... keyCodes)
Constructor specifying the text component to listen to.

Parameters:
source - Text component to listen to.
keyCodes - Virtual key codes (KeyEvent#VK_*).
Method Detail

getKeyEventId

public int getKeyEventId()

setKeyEventId

public void setKeyEventId(int keyEventId)

getModifiers

public int getModifiers()

setModifiers

public void setModifiers(int modifiersMask)

setModifiers

public void setModifiers(int modifiersMask,
                         boolean strictModifiersMatch)

getKeys

public Collection<Integer> getKeys()
Gets the key codes for which the validation will be triggered.
Key codes correspond to KeyEvent#VK_*.

Returns:
Key codes for which the validation will be triggered.

addKey

public void addKey(int keyCode)
Adds a key code for which the validation will be triggered.
Key codes correspond to KeyEvent#VK_*.

Parameters:
keyCode - Key code to be added to trigger the validation.

removeKey

public void removeKey(int keyCode)
Removes a key code for which the validation should no longer be triggered.
Key codes correspond to KeyEvent#VK_*.

Parameters:
keyCode - Key code to be removed.

getComponent

public C getComponent()
Gets the source component.

Returns:
Source component.

dispose

public void dispose()
Specified by:
dispose in interface com.google.code.validationframework.api.common.Disposable
Overrides:
dispose in class com.google.code.validationframework.base.trigger.AbstractTrigger
See Also:
Disposable.dispose()


Copyright © 2013. All Rights Reserved.