Search in sources :

Example 1 with ActiveEvent

use of java.awt.ActiveEvent in project hackpad by dropbox.

the class RunProxy method dispatchNextGuiEvent.

/**
     * Processes the next GUI event.
     */
public void dispatchNextGuiEvent() throws InterruptedException {
    EventQueue queue = awtEventQueue;
    if (queue == null) {
        queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
        awtEventQueue = queue;
    }
    AWTEvent event = queue.getNextEvent();
    if (event instanceof ActiveEvent) {
        ((ActiveEvent) event).dispatch();
    } else {
        Object source = event.getSource();
        if (source instanceof Component) {
            Component comp = (Component) source;
            comp.dispatchEvent(event);
        } else if (source instanceof MenuComponent) {
            ((MenuComponent) source).dispatchEvent(event);
        }
    }
}
Also used : ActiveEvent(java.awt.ActiveEvent) AWTEvent(java.awt.AWTEvent) EventObject(java.util.EventObject) MenuComponent(java.awt.MenuComponent) Component(java.awt.Component) MenuComponent(java.awt.MenuComponent) EventQueue(java.awt.EventQueue)

Example 2 with ActiveEvent

use of java.awt.ActiveEvent in project jodd by oblac.

the class CaddyDialog method setVisible.

@Override
public void setVisible(boolean visible) {
    boolean blockParent = (visible && modal);
    owner.setEnabled(!blockParent);
    owner.setFocusableWindowState(!blockParent);
    super.setVisible(visible);
    if (blockParent) {
        owner.addWindowListener(parentWindowListener);
        try {
            if (SwingUtilities.isEventDispatchThread()) {
                EventQueue theQueue = getToolkit().getSystemEventQueue();
                while (isVisible()) {
                    AWTEvent event = theQueue.getNextEvent();
                    Object src = event.getSource();
                    if (event instanceof ActiveEvent) {
                        ((ActiveEvent) event).dispatch();
                    } else if (src instanceof Component) {
                        ((Component) src).dispatchEvent(event);
                    }
                }
            } else {
                synchronized (getTreeLock()) {
                    while (isVisible()) {
                        try {
                            getTreeLock().wait();
                        } catch (InterruptedException e) {
                            break;
                        }
                    }
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    } else {
        owner.removeWindowListener(parentWindowListener);
        // added 2 lines
        owner.setEnabled(true);
        owner.setFocusableWindowState(true);
    }
}
Also used : ActiveEvent(java.awt.ActiveEvent) AWTEvent(java.awt.AWTEvent) Component(java.awt.Component) EventQueue(java.awt.EventQueue)

Aggregations

AWTEvent (java.awt.AWTEvent)2 ActiveEvent (java.awt.ActiveEvent)2 Component (java.awt.Component)2 EventQueue (java.awt.EventQueue)2 MenuComponent (java.awt.MenuComponent)1 EventObject (java.util.EventObject)1