Java Code Examples for sun.awt.SunToolkit#flushPendingEvents()

The following examples show how to use sun.awt.SunToolkit#flushPendingEvents() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventQueue.java    From jdk-1.7-annotated with Apache License 2.0 6 votes vote down vote up
/**
 * Removes an event from the <code>EventQueue</code> and
 * returns it.  This method will block until an event has
 * been posted by another thread.
 * @return the next <code>AWTEvent</code>
 * @exception InterruptedException
 *            if any thread has interrupted this thread
 */
public AWTEvent getNextEvent() throws InterruptedException {
    do {
        /*
         * SunToolkit.flushPendingEvents must be called outside
         * of the synchronized block to avoid deadlock when
         * event queues are nested with push()/pop().
         */
        SunToolkit.flushPendingEvents(appContext);
        pushPopLock.lock();
        try {
            AWTEvent event = getNextEventPrivate();
            if (event != null) {
                return event;
            }
            AWTAutoShutdown.getInstance().notifyThreadFree(dispatchThread);
            pushPopCond.await();
        } finally {
            pushPopLock.unlock();
        }
    } while(true);
}
 
Example 2
Source File: Robot.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Waits until all events currently on the event queue have been processed.
 * @throws  IllegalThreadStateException if called on the AWT event dispatching thread
 */
public synchronized void waitForIdle() {
    checkNotDispatchThread();
    // post a dummy event to the queue so we know when
    // all the events before it have been processed
    try {
        SunToolkit.flushPendingEvents();
        EventQueue.invokeAndWait( new Runnable() {
                                        public void run() {
                                            // dummy implementation
                                        }
                                    } );
    } catch(InterruptedException ite) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ite.printStackTrace();
    } catch(InvocationTargetException ine) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ine.printStackTrace();
    }
}
 
Example 3
Source File: Robot.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
/**
 * Waits until all events currently on the event queue have been processed.
 * @throws  IllegalThreadStateException if called on the AWT event dispatching thread
 */
public synchronized void waitForIdle() {
    checkNotDispatchThread();
    // post a dummy event to the queue so we know when
    // all the events before it have been processed
    try {
        SunToolkit.flushPendingEvents();
        EventQueue.invokeAndWait( new Runnable() {
                                        public void run() {
                                            // dummy implementation
                                        }
                                    } );
    } catch(InterruptedException ite) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ite.printStackTrace();
    } catch(InvocationTargetException ine) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ine.printStackTrace();
    }
}
 
Example 4
Source File: Robot.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Waits until all events currently on the event queue have been processed.
 * @throws  IllegalThreadStateException if called on the AWT event dispatching thread
 */
public synchronized void waitForIdle() {
    checkNotDispatchThread();
    // post a dummy event to the queue so we know when
    // all the events before it have been processed
    try {
        SunToolkit.flushPendingEvents();
        EventQueue.invokeAndWait( new Runnable() {
                                        public void run() {
                                            // dummy implementation
                                        }
                                    } );
    } catch(InterruptedException ite) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ite.printStackTrace();
    } catch(InvocationTargetException ine) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ine.printStackTrace();
    }
}
 
Example 5
Source File: Robot.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Waits until all events currently on the event queue have been processed.
 * @throws  IllegalThreadStateException if called on the AWT event dispatching thread
 */
public synchronized void waitForIdle() {
    checkNotDispatchThread();
    // post a dummy event to the queue so we know when
    // all the events before it have been processed
    try {
        SunToolkit.flushPendingEvents();
        EventQueue.invokeAndWait( new Runnable() {
                                        public void run() {
                                            // dummy implementation
                                        }
                                    } );
    } catch(InterruptedException ite) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ite.printStackTrace();
    } catch(InvocationTargetException ine) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ine.printStackTrace();
    }
}
 
Example 6
Source File: Robot.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Waits until all events currently on the event queue have been processed.
 * @throws  IllegalThreadStateException if called on the AWT event dispatching thread
 */
public synchronized void waitForIdle() {
    checkNotDispatchThread();
    // post a dummy event to the queue so we know when
    // all the events before it have been processed
    try {
        SunToolkit.flushPendingEvents();
        EventQueue.invokeAndWait( new Runnable() {
                                        public void run() {
                                            // dummy implementation
                                        }
                                    } );
    } catch(InterruptedException ite) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ite.printStackTrace();
    } catch(InvocationTargetException ine) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ine.printStackTrace();
    }
}
 
Example 7
Source File: Robot.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Waits until all events currently on the event queue have been processed.
 * @throws  IllegalThreadStateException if called on the AWT event dispatching thread
 */
public synchronized void waitForIdle() {
    checkNotDispatchThread();
    // post a dummy event to the queue so we know when
    // all the events before it have been processed
    try {
        SunToolkit.flushPendingEvents();
        EventQueue.invokeAndWait( new Runnable() {
                                        public void run() {
                                            // dummy implementation
                                        }
                                    } );
    } catch(InterruptedException ite) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ite.printStackTrace();
    } catch(InvocationTargetException ine) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ine.printStackTrace();
    }
}
 
Example 8
Source File: Robot.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Waits until all events currently on the event queue have been processed.
 * @throws  IllegalThreadStateException if called on the AWT event dispatching thread
 */
public synchronized void waitForIdle() {
    checkNotDispatchThread();
    // post a dummy event to the queue so we know when
    // all the events before it have been processed
    try {
        SunToolkit.flushPendingEvents();
        EventQueue.invokeAndWait( new Runnable() {
                                        public void run() {
                                            // dummy implementation
                                        }
                                    } );
    } catch(InterruptedException ite) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ite.printStackTrace();
    } catch(InvocationTargetException ine) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ine.printStackTrace();
    }
}
 
Example 9
Source File: Robot.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Waits until all events currently on the event queue have been processed.
 * @throws  IllegalThreadStateException if called on the AWT event dispatching thread
 */
public synchronized void waitForIdle() {
    checkNotDispatchThread();
    // post a dummy event to the queue so we know when
    // all the events before it have been processed
    try {
        SunToolkit.flushPendingEvents();
        EventQueue.invokeAndWait( new Runnable() {
                                        public void run() {
                                            // dummy implementation
                                        }
                                    } );
    } catch(InterruptedException ite) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ite.printStackTrace();
    } catch(InvocationTargetException ine) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ine.printStackTrace();
    }
}
 
Example 10
Source File: Robot.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Waits until all events currently on the event queue have been processed.
 * @throws  IllegalThreadStateException if called on the AWT event dispatching thread
 */
public synchronized void waitForIdle() {
    checkNotDispatchThread();
    // post a dummy event to the queue so we know when
    // all the events before it have been processed
    try {
        SunToolkit.flushPendingEvents();
        EventQueue.invokeAndWait( new Runnable() {
                                        public void run() {
                                            // dummy implementation
                                        }
                                    } );
    } catch(InterruptedException ite) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ite.printStackTrace();
    } catch(InvocationTargetException ine) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ine.printStackTrace();
    }
}
 
Example 11
Source File: Robot.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Waits until all events currently on the event queue have been processed.
 * @throws  IllegalThreadStateException if called on the AWT event dispatching thread
 */
public synchronized void waitForIdle() {
    checkNotDispatchThread();
    // post a dummy event to the queue so we know when
    // all the events before it have been processed
    try {
        SunToolkit.flushPendingEvents();
        EventQueue.invokeAndWait( new Runnable() {
                                        public void run() {
                                            // dummy implementation
                                        }
                                    } );
    } catch(InterruptedException ite) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ite.printStackTrace();
    } catch(InvocationTargetException ine) {
        System.err.println("Robot.waitForIdle, non-fatal exception caught:");
        ine.printStackTrace();
    }
}
 
Example 12
Source File: WComponentPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
void paintDamagedAreaImmediately() {
    // force Windows to send any pending WM_PAINT events so
    // the damage area is updated on the Java side
    updateWindow();
    // make sure paint events are transferred to main event queue
    // for coalescing
    SunToolkit.flushPendingEvents();
    // paint the damaged area
    paintArea.paint(target, shouldClearRectBeforePaint());
}
 
Example 13
Source File: WComponentPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
void paintDamagedAreaImmediately() {
    // force Windows to send any pending WM_PAINT events so
    // the damage area is updated on the Java side
    updateWindow();
    // make sure paint events are transferred to main event queue
    // for coalescing
    SunToolkit.flushPendingEvents();
    // paint the damaged area
    paintArea.paint(target, shouldClearRectBeforePaint());
}
 
Example 14
Source File: WComponentPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
void paintDamagedAreaImmediately() {
    // force Windows to send any pending WM_PAINT events so
    // the damage area is updated on the Java side
    updateWindow();
    // make sure paint events are transferred to main event queue
    // for coalescing
    SunToolkit.flushPendingEvents();
    // paint the damaged area
    paintArea.paint(target, shouldClearRectBeforePaint());
}
 
Example 15
Source File: EventQueue.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
AWTEvent getNextEvent(int id) throws InterruptedException {
    do {
        /*
         * SunToolkit.flushPendingEvents must be called outside
         * of the synchronized block to avoid deadlock when
         * event queues are nested with push()/pop().
         */
        SunToolkit.flushPendingEvents(appContext);
        pushPopLock.lock();
        try {
            for (int i = 0; i < NUM_PRIORITIES; i++) {
                for (EventQueueItem entry = queues[i].head, prev = null;
                     entry != null; prev = entry, entry = entry.next)
                {
                    if (entry.event.getID() == id) {
                        if (prev == null) {
                            queues[i].head = entry.next;
                        } else {
                            prev.next = entry.next;
                        }
                        if (queues[i].tail == entry) {
                            queues[i].tail = prev;
                        }
                        uncacheEQItem(entry);
                        return entry.event;
                    }
                }
            }
            waitForID = id;
            pushPopCond.await();
            waitForID = 0;
        } finally {
            pushPopLock.unlock();
        }
    } while(true);
}
 
Example 16
Source File: WComponentPeer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
void paintDamagedAreaImmediately() {
    // force Windows to send any pending WM_PAINT events so
    // the damage area is updated on the Java side
    updateWindow();
    // make sure paint events are transferred to main event queue
    // for coalescing
    SunToolkit.flushPendingEvents();
    // paint the damaged area
    paintArea.paint(target, shouldClearRectBeforePaint());
}
 
Example 17
Source File: WComponentPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
void paintDamagedAreaImmediately() {
    // force Windows to send any pending WM_PAINT events so
    // the damage area is updated on the Java side
    updateWindow();
    // make sure paint events are transferred to main event queue
    // for coalescing
    SunToolkit.flushPendingEvents();
    // paint the damaged area
    paintArea.paint(target, shouldClearRectBeforePaint());
}
 
Example 18
Source File: WComponentPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
void paintDamagedAreaImmediately() {
    // force Windows to send any pending WM_PAINT events so
    // the damage area is updated on the Java side
    updateWindow();
    // make sure paint events are transferred to main event queue
    // for coalescing
    SunToolkit.flushPendingEvents();
    // paint the damaged area
    paintArea.paint(target, shouldClearRectBeforePaint());
}
 
Example 19
Source File: EventQueue.java    From jdk-1.7-annotated with Apache License 2.0 4 votes vote down vote up
final void removeSourceEvents(Object source, boolean removeAllEvents) {
    SunToolkit.flushPendingEvents(appContext);
    pushPopLock.lock();
    try {
        for (int i = 0; i < NUM_PRIORITIES; i++) {
            EventQueueItem entry = queues[i].head;
            EventQueueItem prev = null;
            while (entry != null) {
                if ((entry.event.getSource() == source)
                    && (removeAllEvents
                        || ! (entry.event instanceof SequencedEvent
                              || entry.event instanceof SentEvent
                              || entry.event instanceof FocusEvent
                              || entry.event instanceof WindowEvent
                              || entry.event instanceof KeyEvent
                              || entry.event instanceof InputMethodEvent)))
                {
                    if (entry.event instanceof SequencedEvent) {
                        ((SequencedEvent)entry.event).dispose();
                    }
                    if (entry.event instanceof SentEvent) {
                        ((SentEvent)entry.event).dispose();
                    }
                    if (entry.event instanceof InvocationEvent) {
                        AWTAccessor.getInvocationEventAccessor()
                                .dispose((InvocationEvent)entry.event);
                    }
                    if (prev == null) {
                        queues[i].head = entry.next;
                    } else {
                        prev.next = entry.next;
                    }
                    uncacheEQItem(entry);
                } else {
                    prev = entry;
                }
                entry = entry.next;
            }
            queues[i].tail = prev;
        }
    } finally {
        pushPopLock.unlock();
    }
}
 
Example 20
Source File: Robot.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Waits until all events currently on the event queue have been processed.
 * @throws  IllegalThreadStateException if called on the AWT event dispatching thread
 */
public synchronized void waitForIdle() {
    checkNotDispatchThread();
    SunToolkit.flushPendingEvents();
    ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
}