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

java.lang.Object
  extended by com.google.code.validationframework.base.trigger.AbstractTrigger
      extended by com.google.code.validationframework.swing.trigger.BaseComponentKeyStrokeTrigger<C>
All Implemented Interfaces:
com.google.code.validationframework.api.common.Disposable, com.google.code.validationframework.api.trigger.Trigger
Direct Known Subclasses:
ComponentKeyStrokeTrigger, JFormattedTextFieldKeyStrokeTrigger, JTextAreaKeyStrokeTrigger, JTextFieldKeyStrokeTrigger

public class BaseComponentKeyStrokeTrigger<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 registered key strokes happen on a 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
BaseComponentKeyStrokeTrigger(C source, KeyStroke... keyStrokes)
          Constructor specifying the text component to listen to and the key stroke to trigger the validation.
 
Method Summary
 void addKeyStroke(KeyStroke keyStroke)
          Adds a key stroke for which the validation will be triggered.
 void dispose()
           
 C getComponent()
          Gets the source component.
 Collection<KeyStroke> getKeyStokes()
          Gets the key strokes for which the validation will be triggered.
 void removeKey(KeyStroke keyStroke)
          Removes a key stroke for which the validation should no longer be triggered.
 
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

BaseComponentKeyStrokeTrigger

public BaseComponentKeyStrokeTrigger(C source,
                                     KeyStroke... keyStrokes)
Constructor specifying the text component to listen to and the key stroke to trigger the validation.

If no key stroke is provided, the trigger will initiate the validation on any key stroke.

You may use KeyStroke utility methods to build a KeyStroke.

Parameters:
source - Text component to listen to.
keyStrokes - Key strokes to trigger the validation.
See Also:
KeyStroke
Method Detail

getComponent

public C getComponent()
Gets the source component.

Returns:
Source component.

getKeyStokes

public Collection<KeyStroke> getKeyStokes()
Gets the key strokes for which the validation will be triggered.

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

addKeyStroke

public void addKeyStroke(KeyStroke keyStroke)
Adds a key stroke for which the validation will be triggered.

You may use KeyStroke utility methods to build a KeyStroke.

Parameters:
keyStroke - Key stroke to be added to trigger the validation.
See Also:
KeyStroke

removeKey

public void removeKey(KeyStroke keyStroke)
Removes a key stroke for which the validation should no longer be triggered.

If all key strokes are removed, the trigger will initiate the validation on any key stroke.

Parameters:
keyStroke - Key stroke to be removed.

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.