Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.flexstor.common.awt
Class KeyWatcher  view KeyWatcher download KeyWatcher.java

java.lang.Object
  extended bycom.flexstor.common.awt.KeyWatcher
All Implemented Interfaces:
java.awt.event.ContainerListener, java.util.EventListener

public class KeyWatcher
extends java.lang.Object
implements java.awt.event.ContainerListener

Adds the controller as a key listener for all items (and sub items) in a container. This is done by watching the container and automatically adding and removing key listeners as other containers or components are added or removed. Please Note: 1. setController() not only sets the controller, but also does an inital pass through the target container and adds any items already in that container. 2. The controller MUST implement KeyListener. 3. Implement canProcessComponent() to controll which components are included or excluded.

Version:
2.0

Field Summary
private  java.awt.event.KeyListener controller
           
private  java.awt.Container target
           
private  java.util.Vector vExcludeVector
           
 
Constructor Summary
KeyWatcher(java.awt.Container target)
          Creates a new key watcher.
KeyWatcher(java.awt.Container target, java.awt.event.KeyListener controller)
          Creates a new key watcher.
 
Method Summary
 void addExclusion(java.lang.Class c)
           
protected  boolean canProcessComponent(java.awt.Component c)
          Controls if a components is included or excluded from key watching.
 void componentAdded(java.awt.event.ContainerEvent e)
          Required for the container lister -- DO NOT CALL THIS METHOD DIRECTLY!
 void componentRemoved(java.awt.event.ContainerEvent e)
          Required for the container lister -- DO NOT CALL THIS METHOD DIRECTLY!
private  void configureListeners(java.awt.Component c)
          Adds a keyListener for c and all components within c.
 void removeExclusion(java.lang.Class c)
           
 void setController(java.awt.event.KeyListener controller)
          Sets the controller that will be added as a key listener.
private  void unconfigureListeners(java.awt.Component c)
          Removes the keyListener for c and all components within c.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

controller

private java.awt.event.KeyListener controller

target

private java.awt.Container target

vExcludeVector

private java.util.Vector vExcludeVector
Constructor Detail

KeyWatcher

public KeyWatcher(java.awt.Container target)
Creates a new key watcher.


KeyWatcher

public KeyWatcher(java.awt.Container target,
                  java.awt.event.KeyListener controller)
Creates a new key watcher.

Method Detail

addExclusion

public void addExclusion(java.lang.Class c)

removeExclusion

public void removeExclusion(java.lang.Class c)

canProcessComponent

protected boolean canProcessComponent(java.awt.Component c)
Controls if a components is included or excluded from key watching. Returns true if this component can be watched, or false to exclude it.


setController

public void setController(java.awt.event.KeyListener controller)
Sets the controller that will be added as a key listener. Also does an inital pass through the target container.


componentAdded

public void componentAdded(java.awt.event.ContainerEvent e)
Required for the container lister -- DO NOT CALL THIS METHOD DIRECTLY!

Specified by:
componentAdded in interface java.awt.event.ContainerListener

componentRemoved

public void componentRemoved(java.awt.event.ContainerEvent e)
Required for the container lister -- DO NOT CALL THIS METHOD DIRECTLY!

Specified by:
componentRemoved in interface java.awt.event.ContainerListener

configureListeners

private void configureListeners(java.awt.Component c)
Adds a keyListener for c and all components within c.


unconfigureListeners

private void unconfigureListeners(java.awt.Component c)
Removes the keyListener for c and all components within c.