Event Generator and Listener in Java