public synchronized < T extends EventListener > void add ( Class < T > type , T listener ) { assert listener != null ; if ( this . listeners == NULL ) { // if this is the first listener added, // initialize the lists this . listeners = new Object [ ] { type , listener } ; } else { // Otherwise copy the array and add the new listener final int i = this . listeners . length ; final Object [ ] tmp = new Object [ i + 2 ] ; System . arraycopy ( this . listeners , 0 , tmp , 0 , i ) ; tmp [ i ] = type ; tmp [ i + 1 ] = listener ; this . listeners = tmp ; } }
Adds the listener as a listener of the specified type .