Java Code Examples for java.awt.EventQueue#postEvent()

The following examples show how to use java.awt.EventQueue#postEvent() . 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: EventLock.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Similar to {@link EventQueue#invokeAndWait} but posts the event at the same
 * priority as paint requests, to avoid bad visual artifacts.
 */
static void invokeAndWaitLowPriority(RWLock m, Runnable r)
        throws InterruptedException, InvocationTargetException {
    Toolkit t = Toolkit.getDefaultToolkit();
    EventQueue q = t.getSystemEventQueue();
    Object lock = new PaintPriorityEventLock();
    InvocationEvent ev = new PaintPriorityEvent(m, t, r, lock, true);
    synchronized (lock) {
        q.postEvent(ev);
        lock.wait();
    }
    Exception e = ev.getException();
    if (e != null) {
        throw new InvocationTargetException(e);
    }
}
 
Example 2
Source File: Keyboard.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
private void postKeyEventToEventQueue(int modifiers, int keyCode) {
    EventQueue queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
    Frame eventSource = pw.target();
    queue.postEvent(new KeyEvent(eventSource, KEY_PRESSED,
        System.currentTimeMillis(), modifiers,
        keyCode, Character.MIN_VALUE));
    queue.postEvent(new KeyEvent(eventSource, KEY_RELEASED,
        System.currentTimeMillis(), modifiers,
        keyCode, Character.MIN_VALUE));
}
 
Example 3
Source File: AppContext.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final EventQueue eq = (EventQueue)appContext.get(EVENT_QUEUE_KEY);
    if (eq != null) {
        eq.postEvent(AWTAutoShutdown.getShutdownEvent());
    }
}
 
Example 4
Source File: AppContext.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final EventQueue eq = (EventQueue)appContext.get(EVENT_QUEUE_KEY);
    if (eq != null) {
        eq.postEvent(AWTAutoShutdown.getShutdownEvent());
    }
}
 
Example 5
Source File: AppContext.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final EventQueue eq = (EventQueue)appContext.get(EVENT_QUEUE_KEY);
    if (eq != null) {
        eq.postEvent(AWTAutoShutdown.getShutdownEvent());
    }
}
 
Example 6
Source File: AppContext.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final EventQueue eq = (EventQueue)appContext.get(EVENT_QUEUE_KEY);
    if (eq != null) {
        eq.postEvent(AWTAutoShutdown.getShutdownEvent());
    }
}
 
Example 7
Source File: AppContext.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final EventQueue eq = (EventQueue)appContext.get(EVENT_QUEUE_KEY);
    if (eq != null) {
        eq.postEvent(AWTAutoShutdown.getShutdownEvent());
    }
}
 
Example 8
Source File: AppContext.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final EventQueue eq = (EventQueue)appContext.get(EVENT_QUEUE_KEY);
    if (eq != null) {
        eq.postEvent(AWTAutoShutdown.getShutdownEvent());
    }
}
 
Example 9
Source File: AppContext.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final EventQueue eq = (EventQueue)appContext.get(EVENT_QUEUE_KEY);
    if (eq != null) {
        eq.postEvent(AWTAutoShutdown.getShutdownEvent());
    }
}
 
Example 10
Source File: AppContext.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final EventQueue eq = (EventQueue)appContext.get(EVENT_QUEUE_KEY);
    if (eq != null) {
        eq.postEvent(AWTAutoShutdown.getShutdownEvent());
    }
}
 
Example 11
Source File: AppContext.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final EventQueue eq = (EventQueue)appContext.get(EVENT_QUEUE_KEY);
    if (eq != null) {
        eq.postEvent(AWTAutoShutdown.getShutdownEvent());
    }
}
 
Example 12
Source File: AppContext.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public void run() {
    final EventQueue eq = (EventQueue)appContext.get(EVENT_QUEUE_KEY);
    if (eq != null) {
        eq.postEvent(AWTAutoShutdown.getShutdownEvent());
    }
}
 
Example 13
Source File: AppContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final EventQueue eq = (EventQueue)appContext.get(EVENT_QUEUE_KEY);
    if (eq != null) {
        eq.postEvent(AWTAutoShutdown.getShutdownEvent());
    }
}
 
Example 14
Source File: EventLock.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Similar to {@link EventQueue#invokeLater} but posts the event at the same
 * priority as paint requests, to avoid bad visual artifacts.
 */
static void invokeLaterLowPriority(RWLock m, Runnable r) {
    Toolkit t = Toolkit.getDefaultToolkit();
    EventQueue q = t.getSystemEventQueue();
    q.postEvent(new PaintPriorityEvent(m, t, r, null, false));
}
 
Example 15
Source File: AppContext.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final EventQueue eq = (EventQueue)appContext.get(EVENT_QUEUE_KEY);
    if (eq != null) {
        eq.postEvent(AWTAutoShutdown.getShutdownEvent());
    }
}
 
Example 16
Source File: AppContext.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final EventQueue eq = (EventQueue)appContext.get(EVENT_QUEUE_KEY);
    if (eq != null) {
        eq.postEvent(AWTAutoShutdown.getShutdownEvent());
    }
}
 
Example 17
Source File: AppContext.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final EventQueue eq = (EventQueue)appContext.get(EVENT_QUEUE_KEY);
    if (eq != null) {
        eq.postEvent(AWTAutoShutdown.getShutdownEvent());
    }
}