Examples of EventQueue


Examples of java.awt.EventQueue

        };

        final JDesktopPane desktop = toolkit.getAwtContext().getDesktop();
        AppContext ac = SunToolkit.targetToAppContext(desktop);
        if (ac != null) {
            EventQueue eq = (EventQueue) ac.get(AppContext.EVENT_QUEUE_KEY);
            if (eq != null) {
                eq.postEvent(new InvocationEvent(Toolkit.getDefaultToolkit(), run));
                return;
            }
        }
        //shouldn't get here
        throw new RuntimeException("Desktop event queue not found!");
View Full Code Here

Examples of java.awt.EventQueue

                //peer frames should be created in the same app context where the desktop is
                //todo refactor this into a generic inter-appcontext invoke and wait
                AppContext ac = SunToolkit.targetToAppContext(target);
                if (ac != null) {
                    EventQueue eq = (EventQueue) ac.get(sun.awt.AppContext.EVENT_QUEUE_KEY);
                    if (eq != null) {
                        try {
                            Method met = EventQueue.class.getDeclaredMethod("initDispatchThread");
                            met.setAccessible(true);
                            met.invoke(eq);
                        } catch (Exception x) {
                            x.printStackTrace();
                        }
                    }
                }

                // invoke and wait --
                EventQueue eq = getMainEventQueue();

                if (eq == getSystemEventQueueImpl()) {
                    run.run();
                    synchronized (ret) {
                        return ret[0];
                    }
                }

                try {
                    Field field = EventQueue.class.getField("dispatchThread");
                    field.setAccessible(true);
                    Thread edt = (Thread) field.get(eq);
                    if (Thread.currentThread() == edt) {
                        run.run();
                        synchronized (ret) {
                            return ret[0];
                        }
                    }
                } catch (Exception x) {
                    throw new RuntimeException(x);
                }

                class AWTInvocationLock {
                }
                Object lock = new AWTInvocationLock();

                InvocationEvent event = new InvocationEvent(Toolkit.getDefaultToolkit(), run, lock, true);

                try {
                    synchronized (lock) {
                        eq.postEvent(event);
                        lock.wait();
                    }
                } catch (Exception x) {
                    throw new RuntimeException(x);
                }
View Full Code Here

Examples of java.awt.EventQueue

    protected final void processEvent(AWTEvent event) {
        AppContext ac = SunToolkit.targetToAppContext(target);
        if (ac == null) {
            target.dispatchEvent(SwingToolkit.convertEvent(event, target));
        } else {
            EventQueue eq = (EventQueue) ac.get(AppContext.EVENT_QUEUE_KEY);
            if (eq == null) {
                target.dispatchEvent(SwingToolkit.convertEvent(event, target));
            } else {
                eq.postEvent(SwingToolkit.convertEvent(event, target));
            }
        }
    }
View Full Code Here

Examples of java.awt.EventQueue

     * @return The event queue
     */
    protected final EventQueue getSystemEventQueueImpl() {
        AppContext ac = AppContext.getAppContext();
        if (ac != null) {
            EventQueue eq = (EventQueue) ac.get(AppContext.EVENT_QUEUE_KEY);
            if (eq != null) {
                return eq;
            }
        }

View Full Code Here

Examples of java.awt.EventQueue

                screenSize.width = config.getConfig().getScreenWidth();
                screenSize.height = config.getConfig().getScreenHeight();

                //drawStartupScreen();

                final EventQueue eventQueue = getSystemEventQueueImpl();
                this.keyboardHandler = new KeyboardHandler(eventQueue);
                this.mouseHandler = new MouseHandler(fbDevice.getDevice(),
                    screenSize, eventQueue, keyboardHandler);
                keyboardHandler.install();
View Full Code Here

Examples of java.awt.EventQueue

        // TODO Auto-generated method stub

    }

    public void wakeNativeQueue() {
        final EventQueue q = this.waitingNativeQueue;
        if (q != null) {
            synchronized (q) {
                q.notifyAll();
            }
        }
    }
View Full Code Here

Examples of java.awt.EventQueue

        }
        getSystemEventQueueImpl().postEvent(event);
    }

    public static void postToTarget(ComponentEvent event, Component target) {
        EventQueue queue;
        AppContext ac = SunToolkit.targetToAppContext(target);
        if (ac == null) {
            queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
        } else {
            queue = (EventQueue) ac.get(sun.awt.AppContext.EVENT_QUEUE_KEY);
            if (queue == null) {
                queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
            }
        }

        queue.postEvent(event);
    }
View Full Code Here

Examples of java.awt.EventQueue

            }
        }
    }

    private void waitForIdleEventQueue() {
        EventQueue queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
        while (queue.peekEvent() != null) {
            try {
                sleep(eqSleepTime);
            }
            catch (InterruptedException ie) {
            }
View Full Code Here

Examples of java.awt.EventQueue

  public void close(Window w) {
    WindowEvent event = new WindowEvent(w, WINDOW_CLOSING);
    // If the window contains an applet, send the event on the applet's queue instead to ensure a shutdown from the
    // applet's context (assists AppletViewer cleanup).
    Component applet = findAppletDescendent(w);
    EventQueue eventQueue = windowMonitor.eventQueueFor(applet != null ? applet : w);
    eventQueue.postEvent(event);
    waitForIdle();
  }
View Full Code Here

Examples of java.awt.EventQueue

  final Map<Component, WeakReference<EventQueue>> queueMap = new WeakHashMap<Component, WeakReference<EventQueue>>();

  @RunsInCurrentThread
  void addQueueFor(Component c) {
    EventQueue queue = c.getToolkit().getSystemEventQueue();
    queueMap.put(c, new WeakReference<EventQueue>(queue));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.