Java Code Examples for java.awt.event.KeyEvent#setSource()

The following examples show how to use java.awt.event.KeyEvent#setSource() . 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: DefaultKeyboardFocusManager.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private boolean preDispatchKeyEvent(KeyEvent ke) {
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
    // - A key event is anyway passed to this method which starts its actual dispatching.
    // - If a key event is put to the type ahead queue, its time stamp should not be registered
    //   until its dispatching actually starts (by this method).
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.getPeer();
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (iter.next().
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}
 
Example 2
Source File: DefaultKeyboardFocusManager.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
private boolean preDispatchKeyEvent(KeyEvent ke) {
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
    // - A key event is anyway passed to this method which starts its actual dispatching.
    // - If a key event is put to the type ahead queue, its time stamp should not be registered
    //   until its dispatching actually starts (by this method).
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.getPeer();
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (iter.next().
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}
 
Example 3
Source File: DefaultKeyboardFocusManager.java    From jdk-1.7-annotated with Apache License 2.0 4 votes vote down vote up
private boolean preDispatchKeyEvent(KeyEvent ke) {
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the current event and most recent timestamp here in
    // addition to the call in Component.dispatchEventImpl. Because
    // KeyEvents can be delivered in response to a FOCUS_GAINED event, the
    // current timestamp may be incorrect. We need to set it here so that
    // KeyEventDispatchers will use the correct time.
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.getPeer();
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (((KeyEventDispatcher)(iter.next())).
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}
 
Example 4
Source File: DefaultKeyboardFocusManager.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private boolean preDispatchKeyEvent(KeyEvent ke) {
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
    // - A key event is anyway passed to this method which starts its actual dispatching.
    // - If a key event is put to the type ahead queue, its time stamp should not be registered
    //   until its dispatching actually starts (by this method).
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.getPeer();
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (iter.next().
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}
 
Example 5
Source File: DefaultKeyboardFocusManager.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private boolean preDispatchKeyEvent(KeyEvent ke) {
    getOnTypeaheadFinishedHandler().accept(ke);
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
    // - A key event is anyway passed to this method which starts its actual dispatching.
    // - If a key event is put to the type ahead queue, its time stamp should not be registered
    //   until its dispatching actually starts (by this method).
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.getPeer();
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (iter.next().
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}
 
Example 6
Source File: DefaultKeyboardFocusManager.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private boolean preDispatchKeyEvent(KeyEvent ke) {
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
    // - A key event is anyway passed to this method which starts its actual dispatching.
    // - If a key event is put to the type ahead queue, its time stamp should not be registered
    //   until its dispatching actually starts (by this method).
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.getPeer();
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (iter.next().
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}
 
Example 7
Source File: DefaultKeyboardFocusManager.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private boolean preDispatchKeyEvent(KeyEvent ke) {
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
    // - A key event is anyway passed to this method which starts its actual dispatching.
    // - If a key event is put to the type ahead queue, its time stamp should not be registered
    //   until its dispatching actually starts (by this method).
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.getPeer();
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (iter.next().
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}
 
Example 8
Source File: DefaultKeyboardFocusManager.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private boolean preDispatchKeyEvent(KeyEvent ke) {
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
    // - A key event is anyway passed to this method which starts its actual dispatching.
    // - If a key event is put to the type ahead queue, its time stamp should not be registered
    //   until its dispatching actually starts (by this method).
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.getPeer();
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (iter.next().
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}
 
Example 9
Source File: DefaultKeyboardFocusManager.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
private boolean preDispatchKeyEvent(KeyEvent ke) {
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
    // - A key event is anyway passed to this method which starts its actual dispatching.
    // - If a key event is put to the type ahead queue, its time stamp should not be registered
    //   until its dispatching actually starts (by this method).
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.getPeer();
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (iter.next().
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}
 
Example 10
Source File: DefaultKeyboardFocusManager.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
private boolean preDispatchKeyEvent(KeyEvent ke) {
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
    // - A key event is anyway passed to this method which starts its actual dispatching.
    // - If a key event is put to the type ahead queue, its time stamp should not be registered
    //   until its dispatching actually starts (by this method).
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.getPeer();
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (iter.next().
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}
 
Example 11
Source File: DefaultKeyboardFocusManager.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private boolean preDispatchKeyEvent(KeyEvent ke) {
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
    // - A key event is anyway passed to this method which starts its actual dispatching.
    // - If a key event is put to the type ahead queue, its time stamp should not be registered
    //   until its dispatching actually starts (by this method).
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.peer;
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (iter.next().
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}
 
Example 12
Source File: DefaultKeyboardFocusManager.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private boolean preDispatchKeyEvent(KeyEvent ke) {
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
    // - A key event is anyway passed to this method which starts its actual dispatching.
    // - If a key event is put to the type ahead queue, its time stamp should not be registered
    //   until its dispatching actually starts (by this method).
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.peer;
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (iter.next().
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}
 
Example 13
Source File: DefaultKeyboardFocusManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private boolean preDispatchKeyEvent(KeyEvent ke) {
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
    // - A key event is anyway passed to this method which starts its actual dispatching.
    // - If a key event is put to the type ahead queue, its time stamp should not be registered
    //   until its dispatching actually starts (by this method).
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.getPeer();
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (iter.next().
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}
 
Example 14
Source File: DefaultKeyboardFocusManager.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private boolean preDispatchKeyEvent(KeyEvent ke) {
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
    // - A key event is anyway passed to this method which starts its actual dispatching.
    // - If a key event is put to the type ahead queue, its time stamp should not be registered
    //   until its dispatching actually starts (by this method).
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.getPeer();
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (iter.next().
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}
 
Example 15
Source File: DefaultKeyboardFocusManager.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
private boolean preDispatchKeyEvent(KeyEvent ke) {
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
    // - A key event is anyway passed to this method which starts its actual dispatching.
    // - If a key event is put to the type ahead queue, its time stamp should not be registered
    //   until its dispatching actually starts (by this method).
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.getPeer();
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (iter.next().
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}
 
Example 16
Source File: DefaultKeyboardFocusManager.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private boolean preDispatchKeyEvent(KeyEvent ke) {
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
    // - A key event is anyway passed to this method which starts its actual dispatching.
    // - If a key event is put to the type ahead queue, its time stamp should not be registered
    //   until its dispatching actually starts (by this method).
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.getPeer();
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (iter.next().
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}
 
Example 17
Source File: DefaultKeyboardFocusManager.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private boolean preDispatchKeyEvent(KeyEvent ke) {
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
    // - A key event is anyway passed to this method which starts its actual dispatching.
    // - If a key event is put to the type ahead queue, its time stamp should not be registered
    //   until its dispatching actually starts (by this method).
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.getPeer();
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (iter.next().
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}
 
Example 18
Source File: DefaultKeyboardFocusManager.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private boolean preDispatchKeyEvent(KeyEvent ke) {
    if (((AWTEvent) ke).isPosted) {
        Component focusOwner = getFocusOwner();
        ke.setSource(((focusOwner != null) ? focusOwner : getFocusedWindow()));
    }
    if (ke.getSource() == null) {
        return true;
    }

    // Explicitly set the key event timestamp here (not in Component.dispatchEventImpl):
    // - A key event is anyway passed to this method which starts its actual dispatching.
    // - If a key event is put to the type ahead queue, its time stamp should not be registered
    //   until its dispatching actually starts (by this method).
    EventQueue.setCurrentEventAndMostRecentTime(ke);

    /**
     * Fix for 4495473.
     * This fix allows to correctly dispatch events when native
     * event proxying mechanism is active.
     * If it is active we should redispatch key events after
     * we detected its correct target.
     */
    if (KeyboardFocusManager.isProxyActive(ke)) {
        Component source = (Component)ke.getSource();
        Container target = source.getNativeContainer();
        if (target != null) {
            ComponentPeer peer = target.getPeer();
            if (peer != null) {
                peer.handleEvent(ke);
                /**
                 * Fix for 4478780 - consume event after it was dispatched by peer.
                 */
                ke.consume();
            }
        }
        return true;
    }

    java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
    if (dispatchers != null) {
        for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
             iter.hasNext(); )
         {
             if (iter.next().
                 dispatchKeyEvent(ke))
             {
                 return true;
             }
         }
    }
    return dispatchKeyEvent(ke);
}