Java 类java.awt.ActiveEvent 实例源码

项目:whackpad    文件:SwingGui.java   
/**
 * 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);
        }
    }
}
项目:manifold-ij    文件:ModalEventQueue.java   
public void dispatchEvent( AWTEvent event )
{
  Object src = event.getSource();
  if( event instanceof ActiveEvent )
  {
    ((ActiveEvent)event).dispatch();
  }
  else if( src instanceof Component )
  {
    ((Component)src).dispatchEvent( event );
  }
  else if( src instanceof MenuComponent )
  {
    ((MenuComponent)src).dispatchEvent( event );
  }
}
项目:code404    文件:SwingGui.java   
/**
 * 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);
        }
    }
}
项目:S3F    文件:SwingGui.java   
/**
 * 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);
        }
    }
}
项目:rhino-jscover    文件:SwingGui.java   
/**
 * 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);
        }
    }
}
项目:astor    文件:SwingGui.java   
/**
 * 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);
        }
    }
}
项目:Rhino-Prov-Mod    文件:SwingGui.java   
/**
 * 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);
        }
    }
}
项目:closure-compiler-old    文件:SwingGui.java   
/**
 * 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);
        }
    }
}
项目:closure-compiler-copy    文件:SwingGui.java   
/**
 * 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);
        }
    }
}
项目:minimal-j    文件:SwingInternalFrame.java   
private void showModal() {
    EventQueue theQueue = getToolkit().getSystemEventQueue();
    while (isVisible()) {
        AWTEvent event = null;
        try {
            event = theQueue.getNextEvent();
        } catch (InterruptedException x) {
            LOG.warning(x.getLocalizedMessage());
            continue;
        }
        Object source = event.getSource();

        if (event instanceof MouseEvent) {
            MouseEvent e = (MouseEvent) event;
            MouseEvent m = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, this);
            if (!this.contains(m.getPoint()) && e.getID() != MouseEvent.MOUSE_DRAGGED) {
                continue;
            }
        }

        if (event instanceof ActiveEvent) {
            ((ActiveEvent) event).dispatch();
        } else if (source instanceof Component) {
            ((Component) source).dispatchEvent(event);
        } else if (source instanceof MenuComponent) {
            ((MenuComponent) source).dispatchEvent(event);
        } else {
            LOG.warning("Not dispatched: " + event);
        }
    }
}
项目:minimal-j    文件:EditablePanel.java   
public void lock() {
    lockCount++;
    setCursorRecursive(this, Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    EventQueue theQueue = getToolkit().getSystemEventQueue();
    while (lockCount > 0) {
        AWTEvent event = null;
        try {
            event = theQueue.getNextEvent();
        } catch (InterruptedException x) {
            LOG.warning(x.getLocalizedMessage());
            continue;
        }
        Object source = event.getSource();

        if (event instanceof MouseEvent) {
            continue;
        }

        if (event instanceof ActiveEvent) {
            ((ActiveEvent) event).dispatch();
        } else if (source instanceof Component) {
            ((Component) source).dispatchEvent(event);
        } else if (source instanceof MenuComponent) {
            ((MenuComponent) source).dispatchEvent(event);
        } else {
            LOG.warning("Not dispatched: " + event);
        }
    }
    setCursorRecursive(this, Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
项目:swingspy    文件:CaddyDialog.java   
@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);
    }
}
项目:javify    文件:JOptionPane.java   
/**
 * This helper method makes the JInternalFrame wait until it is notified by
 * an InternalFrameClosing event. This method also adds the given
 * JOptionPane to the JInternalFrame and sizes it according to the
 * JInternalFrame's preferred size.
 *
 * @param f The JInternalFrame to make modal.
 */
private static void startModal(JInternalFrame f)
{
  // We need to add an additional glasspane-like component directly
  // below the frame, which intercepts all mouse events that are not
  // directed at the frame itself.
  JPanel modalInterceptor = new JPanel();
  modalInterceptor.setOpaque(false);
  JLayeredPane lp = JLayeredPane.getLayeredPaneAbove(f);
  lp.setLayer(modalInterceptor, JLayeredPane.MODAL_LAYER.intValue());
  modalInterceptor.setBounds(0, 0, lp.getWidth(), lp.getHeight());
  modalInterceptor.addMouseListener(new MouseAdapter(){});
  modalInterceptor.addMouseMotionListener(new MouseMotionAdapter(){});
  lp.add(modalInterceptor);
  f.toFront();

  // We need to explicitly dispatch events when we are blocking the event
  // dispatch thread.
  EventQueue queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
  try
    {
      while (! f.isClosed())
        {
          if (EventQueue.isDispatchThread())
            {
              // The getNextEventMethod() issues wait() when no
              // event is available, so we don't need do explicitly wait().
              AWTEvent ev = queue.getNextEvent();
              // This mimics EventQueue.dispatchEvent(). We can't use
              // EventQueue.dispatchEvent() directly, because it is
              // protected, unfortunately.
              if (ev instanceof ActiveEvent)
                ((ActiveEvent) ev).dispatch();
              else if (ev.getSource() instanceof Component)
                ((Component) ev.getSource()).dispatchEvent(ev);
              else if (ev.getSource() instanceof MenuComponent)
                ((MenuComponent) ev.getSource()).dispatchEvent(ev);
              // Other events are ignored as per spec in
              // EventQueue.dispatchEvent
            }
          else
            {
              // Give other threads a chance to become active.
              Thread.yield();
            }
        }
    }
  catch (InterruptedException ex)
    {
      // If we get interrupted, then leave the modal state.
    }
  finally
    {
      // Clean up the modal interceptor.
      lp.remove(modalInterceptor);

      // Remove the internal frame from its parent, so it is no longer
      // lurking around and clogging memory.
      Container parent = f.getParent();
      if (parent != null)
        parent.remove(f);
    }
}
项目:jvm-stm    文件:JOptionPane.java   
/**
 * This helper method makes the JInternalFrame wait until it is notified by
 * an InternalFrameClosing event. This method also adds the given
 * JOptionPane to the JInternalFrame and sizes it according to the
 * JInternalFrame's preferred size.
 *
 * @param f The JInternalFrame to make modal.
 */
private static void startModal(JInternalFrame f)
{
  // We need to add an additional glasspane-like component directly
  // below the frame, which intercepts all mouse events that are not
  // directed at the frame itself.
  JPanel modalInterceptor = new JPanel();
  modalInterceptor.setOpaque(false);
  JLayeredPane lp = JLayeredPane.getLayeredPaneAbove(f);
  lp.setLayer(modalInterceptor, JLayeredPane.MODAL_LAYER.intValue());
  modalInterceptor.setBounds(0, 0, lp.getWidth(), lp.getHeight());
  modalInterceptor.addMouseListener(new MouseAdapter(){});
  modalInterceptor.addMouseMotionListener(new MouseMotionAdapter(){});
  lp.add(modalInterceptor);
  f.toFront();

  // We need to explicitly dispatch events when we are blocking the event
  // dispatch thread.
  EventQueue queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
  try
    {
      while (! f.isClosed())
        {
          if (EventQueue.isDispatchThread())
            {
              // The getNextEventMethod() issues wait() when no
              // event is available, so we don't need do explicitly wait().
              AWTEvent ev = queue.getNextEvent();
              // This mimics EventQueue.dispatchEvent(). We can't use
              // EventQueue.dispatchEvent() directly, because it is
              // protected, unfortunately.
              if (ev instanceof ActiveEvent)
                ((ActiveEvent) ev).dispatch();
              else if (ev.getSource() instanceof Component)
                ((Component) ev.getSource()).dispatchEvent(ev);
              else if (ev.getSource() instanceof MenuComponent)
                ((MenuComponent) ev.getSource()).dispatchEvent(ev);
              // Other events are ignored as per spec in
              // EventQueue.dispatchEvent
            }
          else
            {
              // Give other threads a chance to become active.
              Thread.yield();
            }
        }
    }
  catch (InterruptedException ex)
    {
      // If we get interrupted, then leave the modal state.
    }
  finally
    {
      // Clean up the modal interceptor.
      lp.remove(modalInterceptor);

      // Remove the internal frame from its parent, so it is no longer
      // lurking around and clogging memory.
      Container parent = f.getParent();
      if (parent != null)
        parent.remove(f);
    }
}
项目:VarJ    文件:EventQueue.java   
/**
 * Dispatches an event. The manner in which the event is
 * dispatched depends upon the type of the event and the
 * type of the event's source object:
 * <p> </p>
 * <table border=1 summary="Event types, source types, and dispatch methods">
 * <tr>
 *     <th>Event Type</th>
 *     <th>Source Type</th> 
 *     <th>Dispatched To</th>
 * </tr>
 * <tr>
 *     <td>ActiveEvent</td>
 *     <td>Any</td>
 *     <td>event.dispatch()</td>
 * </tr>
 * <tr>
 *     <td>Other</td>
 *     <td>Component</td>
 *     <td>source.dispatchEvent(AWTEvent)</td>
 * </tr>
 * <tr>
 *     <td>Other</td>
 *     <td>MenuComponent</td>
 *     <td>source.dispatchEvent(AWTEvent)</td>
 * </tr>
 * <tr>
 *     <td>Other</td>
 *     <td>Other</td>
 *     <td>No action (ignored)</td>
 * </tr>
 * </table>
 * <p> </p>
 * @param event an instance of <code>java.awt.AWTEvent</code>,
 *      or a subclass of it
 * @throws NullPointerException if <code>event</code> is <code>null</code>
 * @since           1.2
 */
protected void dispatchEvent(AWTEvent event) {
    event.isPosted = true;
    Object src = event.getSource();
    if (event instanceof ActiveEvent) {
        // This could become the sole method of dispatching in time.
        setCurrentEventAndMostRecentTimeImpl(event);

        ((ActiveEvent)event).dispatch();
    } else if (src instanceof Component) {
        ((Component)src).dispatchEvent(event);
        event.dispatched();
    } else if (src instanceof MenuComponent) {
        ((MenuComponent)src).dispatchEvent(event);
    } else if (src instanceof TrayIcon) {
        ((TrayIcon)src).dispatchEvent(event);
    } else if (src instanceof AWTAutoShutdown) {
        if (noEvents()) {
            dispatchThread.stopDispatching();
        }
    } else {
        System.err.println("unable to dispatch event: " + event);
    }
}
项目:JamVM-PH    文件:JOptionPane.java   
/**
 * This helper method makes the JInternalFrame wait until it is notified by
 * an InternalFrameClosing event. This method also adds the given
 * JOptionPane to the JInternalFrame and sizes it according to the
 * JInternalFrame's preferred size.
 *
 * @param f The JInternalFrame to make modal.
 */
private static void startModal(JInternalFrame f)
{
  // We need to add an additional glasspane-like component directly
  // below the frame, which intercepts all mouse events that are not
  // directed at the frame itself.
  JPanel modalInterceptor = new JPanel();
  modalInterceptor.setOpaque(false);
  JLayeredPane lp = JLayeredPane.getLayeredPaneAbove(f);
  lp.setLayer(modalInterceptor, JLayeredPane.MODAL_LAYER.intValue());
  modalInterceptor.setBounds(0, 0, lp.getWidth(), lp.getHeight());
  modalInterceptor.addMouseListener(new MouseAdapter(){});
  modalInterceptor.addMouseMotionListener(new MouseMotionAdapter(){});
  lp.add(modalInterceptor);
  f.toFront();

  // We need to explicitly dispatch events when we are blocking the event
  // dispatch thread.
  EventQueue queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
  try
    {
      while (! f.isClosed())
        {
          if (EventQueue.isDispatchThread())
            {
              // The getNextEventMethod() issues wait() when no
              // event is available, so we don't need do explicitly wait().
              AWTEvent ev = queue.getNextEvent();
              // This mimics EventQueue.dispatchEvent(). We can't use
              // EventQueue.dispatchEvent() directly, because it is
              // protected, unfortunately.
              if (ev instanceof ActiveEvent)
                ((ActiveEvent) ev).dispatch();
              else if (ev.getSource() instanceof Component)
                ((Component) ev.getSource()).dispatchEvent(ev);
              else if (ev.getSource() instanceof MenuComponent)
                ((MenuComponent) ev.getSource()).dispatchEvent(ev);
              // Other events are ignored as per spec in
              // EventQueue.dispatchEvent
            }
          else
            {
              // Give other threads a chance to become active.
              Thread.yield();
            }
        }
    }
  catch (InterruptedException ex)
    {
      // If we get interrupted, then leave the modal state.
    }
  finally
    {
      // Clean up the modal interceptor.
      lp.remove(modalInterceptor);

      // Remove the internal frame from its parent, so it is no longer
      // lurking around and clogging memory.
      Container parent = f.getParent();
      if (parent != null)
        parent.remove(f);
    }
}
项目:classpath    文件:JOptionPane.java   
/**
 * This helper method makes the JInternalFrame wait until it is notified by
 * an InternalFrameClosing event. This method also adds the given
 * JOptionPane to the JInternalFrame and sizes it according to the
 * JInternalFrame's preferred size.
 *
 * @param f The JInternalFrame to make modal.
 */
private static void startModal(JInternalFrame f)
{
  // We need to add an additional glasspane-like component directly
  // below the frame, which intercepts all mouse events that are not
  // directed at the frame itself.
  JPanel modalInterceptor = new JPanel();
  modalInterceptor.setOpaque(false);
  JLayeredPane lp = JLayeredPane.getLayeredPaneAbove(f);
  lp.setLayer(modalInterceptor, JLayeredPane.MODAL_LAYER.intValue());
  modalInterceptor.setBounds(0, 0, lp.getWidth(), lp.getHeight());
  modalInterceptor.addMouseListener(new MouseAdapter(){});
  modalInterceptor.addMouseMotionListener(new MouseMotionAdapter(){});
  lp.add(modalInterceptor);
  f.toFront();

  // We need to explicitly dispatch events when we are blocking the event
  // dispatch thread.
  EventQueue queue = Toolkit.getDefaultToolkit().getSystemEventQueue();
  try
    {
      while (! f.isClosed())
        {
          if (EventQueue.isDispatchThread())
            {
              // The getNextEventMethod() issues wait() when no
              // event is available, so we don't need do explicitly wait().
              AWTEvent ev = queue.getNextEvent();
              // This mimics EventQueue.dispatchEvent(). We can't use
              // EventQueue.dispatchEvent() directly, because it is
              // protected, unfortunately.
              if (ev instanceof ActiveEvent)
                ((ActiveEvent) ev).dispatch();
              else if (ev.getSource() instanceof Component)
                ((Component) ev.getSource()).dispatchEvent(ev);
              else if (ev.getSource() instanceof MenuComponent)
                ((MenuComponent) ev.getSource()).dispatchEvent(ev);
              // Other events are ignored as per spec in
              // EventQueue.dispatchEvent
            }
          else
            {
              // Give other threads a chance to become active.
              Thread.yield();
            }
        }
    }
  catch (InterruptedException ex)
    {
      // If we get interrupted, then leave the modal state.
    }
  finally
    {
      // Clean up the modal interceptor.
      lp.remove(modalInterceptor);

      // Remove the internal frame from its parent, so it is no longer
      // lurking around and clogging memory.
      Container parent = f.getParent();
      if (parent != null)
        parent.remove(f);
    }
}
项目:SOEN6471-FreeCol    文件:FreeColDialog.java   
/**
 * Returns the <code>response</code> when set by
 * <code>setResponse(Object response)</code>.
 * Waits the thread until then.
 *
 * @return The object as set by {@link #setResponse}.
 */
public synchronized T getResponse() {
    // Wait the thread until 'response' is available. Notice that
    // we have to process the events manually if the current
    // thread is the Event Dispatch Thread (EDT).

    try {
        if (SwingUtilities.isEventDispatchThread()) {
            EventQueue theQueue = getToolkit().getSystemEventQueue();

            while (!responseGiven) {
                // This is essentially the body of EventDispatchThread
                AWTEvent event = theQueue.getNextEvent();
                Object src = event.getSource();

                try {
                    // We cannot call theQueue.dispatchEvent, so I
                    // pasted its body here:
                    if (event instanceof ActiveEvent) {
                        ((ActiveEvent) event).dispatch();
                    } else if (src instanceof Component) {
                        ((Component) src).dispatchEvent(event);
                    } else if (src instanceof MenuComponent) {
                        ((MenuComponent) src).dispatchEvent(event);
                    } else {
                        logger.warning("unable to dispatch event: "
                            + event);
                    }
                } finally {
                    continue;
                }
            }
        } else {
            while (!responseGiven) {
                wait();
            }
        }
    } catch (InterruptedException e) {}

    T tempResponse = response;
    response = null;
    responseGiven = false;

    return tempResponse;
}