public static boolean priorityEventPending() {
    ApplicationEx app = ApplicationManagerEx.getApplicationEx();
    if (app != null) {
      app.flushNativeEventQueue();
    }
    AWTEvent event = Toolkit.getDefaultToolkit().getSystemEventQueue().peekEvent();
    return event != null && event.getClass().getName().equals("sun.awt.PeerEvent");
  }
public static boolean priorityEventPending()