FileDocCategorySizeDatePackage
CharacterEventHandler.javaAPI DocExample702Sat Apr 17 23:42:58 BST 2004javathreads.examples.ch08.example5

CharacterEventHandler

public class CharacterEventHandler extends Object

Fields Summary
private Vector
listeners
Constructors Summary
Methods Summary
public voidaddCharacterListener(CharacterListener cl)


        
        listeners.add(cl);
    
public voidfireNewCharacter(CharacterSource source, int c)

        CharacterEvent ce = new CharacterEvent(source, c);
	Enumeration e;
        synchronized(listeners) {
	    e = listeners.elements();
	    while (e.hasMoreElements()) {
                ((CharacterListener) e.nextElement()).newCharacter(ce);
	    }
	}
    
public voidremoveCharacterListener(CharacterListener cl)

        listeners.remove(cl);