/** * Waits for the registered event. If the event is not processed within the specified timeout, * an exception is thrown. * * @throws InterruptedException */ public void await(long timeout, TimeUnit timeUnit) throws InterruptedException { if (!isRegistered) { throw new IllegalStateException("not registered"); } if (!latch.await(timeout, timeUnit)) { throw new IllegalStateException("event synchronizer timeout: event was not processed."); } if (scene == null) { node.removeEventHandler(type, handler); } else { scene.removeEventHandler(type, handler); } isRegistered = false; }