void dispatchEvents(int timeoutMs) {
      SunToolkit.flushPendingEvents();
      try {
        while (true) {
          dispatchInvocationEvents();

          InputEvent event = myInputEvents.poll(timeoutMs, TimeUnit.MILLISECONDS);
          if (event == null) return;

          myInputEventDispatcher.accept(event);
        }
      }
      catch (InterruptedException e) {
        throw new RuntimeException(e);
      }
    }
void dispatchEvents(int timeoutMs)