Java Code Examples for java.awt.event.FocusEvent#FOCUS_LOST

The following examples show how to use java.awt.event.FocusEvent#FOCUS_LOST . 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: KeyboardFocusManager.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
static FocusEvent retargetUnexpectedFocusEvent(FocusEvent fe) {
    synchronized (heavyweightRequests) {
        // Any other case represents a failure condition which we did
        // not expect. We need to clearFocusRequestList() and patch up
        // the event as best as possible.

        if (removeFirstRequest()) {
            return (FocusEvent)retargetFocusEvent(fe);
        }

        Component source = fe.getComponent();
        Component opposite = fe.getOppositeComponent();
        boolean temporary = false;
        if (fe.getID() == FocusEvent.FOCUS_LOST &&
            (opposite == null || isTemporary(opposite, source)))
        {
            temporary = true;
        }
        return new CausedFocusEvent(source, fe.getID(), temporary, opposite,
                                    CausedFocusEvent.Cause.NATIVE_SYSTEM);
    }
}
 
Example 2
Source File: KeyboardFocusManager.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static FocusEvent retargetUnexpectedFocusEvent(FocusEvent fe) {
    synchronized (heavyweightRequests) {
        // Any other case represents a failure condition which we did
        // not expect. We need to clearFocusRequestList() and patch up
        // the event as best as possible.

        if (removeFirstRequest()) {
            return (FocusEvent)retargetFocusEvent(fe);
        }

        Component source = fe.getComponent();
        Component opposite = fe.getOppositeComponent();
        boolean temporary = false;
        if (fe.getID() == FocusEvent.FOCUS_LOST &&
            (opposite == null || isTemporary(opposite, source)))
        {
            temporary = true;
        }
        return new CausedFocusEvent(source, fe.getID(), temporary, opposite,
                                    CausedFocusEvent.Cause.NATIVE_SYSTEM);
    }
}
 
Example 3
Source File: KeyboardFocusManager.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
static FocusEvent retargetUnexpectedFocusEvent(FocusEvent fe) {
    synchronized (heavyweightRequests) {
        // Any other case represents a failure condition which we did
        // not expect. We need to clearFocusRequestList() and patch up
        // the event as best as possible.

        if (removeFirstRequest()) {
            return (FocusEvent)retargetFocusEvent(fe);
        }

        Component source = fe.getComponent();
        Component opposite = fe.getOppositeComponent();
        boolean temporary = false;
        if (fe.getID() == FocusEvent.FOCUS_LOST &&
            (opposite == null || isTemporary(opposite, source)))
        {
            temporary = true;
        }
        return new FocusEvent(source, fe.getID(), temporary, opposite,
                                    FocusEvent.Cause.UNEXPECTED);
    }
}
 
Example 4
Source File: LWTextFieldPeer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Restoring native behavior. We should sets the selection range to zero,
 * when component lost its focus.
 *
 * @param e the focus event
 */
@Override
void handleJavaFocusEvent(final FocusEvent e) {
    if (e.getID() == FocusEvent.FOCUS_LOST) {
        // In order to de-select the selection
        setCaretPosition(0);
    }
    super.handleJavaFocusEvent(e);
}
 
Example 5
Source File: KeyboardFocusManagerPeerImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Override
public void clearGlobalFocusOwner(Window activeWindow) {
    if (activeWindow != null) {
        Component focusOwner = activeWindow.getFocusOwner();
        if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
            focusLog.fine("Clearing global focus owner " + focusOwner);
        }
        if (focusOwner != null) {
            FocusEvent fl = new FocusEvent(focusOwner, FocusEvent.FOCUS_LOST, false, null,
                                                 FocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER);
            SunToolkit.postPriorityEvent(fl);
        }
    }
}
 
Example 6
Source File: KeyboardFocusManagerPeerImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void clearGlobalFocusOwner(Window activeWindow) {
    if (activeWindow != null) {
        Component focusOwner = activeWindow.getFocusOwner();
        if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
            focusLog.fine("Clearing global focus owner " + focusOwner);
        }
        if (focusOwner != null) {
            FocusEvent fl = new CausedFocusEvent(focusOwner, FocusEvent.FOCUS_LOST, false, null,
                                                 CausedFocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER);
            SunToolkit.postPriorityEvent(fl);
        }
    }
}
 
Example 7
Source File: WComponentPeer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("fallthrough")
public void handleEvent(AWTEvent e) {
    int id = e.getID();

    if ((e instanceof InputEvent) && !((InputEvent)e).isConsumed() &&
        ((Component)target).isEnabled())
    {
        if (e instanceof MouseEvent && !(e instanceof MouseWheelEvent)) {
            handleJavaMouseEvent((MouseEvent) e);
        } else if (e instanceof KeyEvent) {
            if (handleJavaKeyEvent((KeyEvent)e)) {
                return;
            }
        }
    }

    switch(id) {
        case PaintEvent.PAINT:
            // Got native painting
            paintPending = false;
            // Fallthrough to next statement
        case PaintEvent.UPDATE:
            // Skip all painting while layouting and all UPDATEs
            // while waiting for native paint
            if (!isLayouting && ! paintPending) {
                paintArea.paint(target,shouldClearRectBeforePaint());
            }
            return;
        case FocusEvent.FOCUS_LOST:
        case FocusEvent.FOCUS_GAINED:
            handleJavaFocusEvent((FocusEvent)e);
        default:
        break;
    }

    // Call the native code
    nativeHandleEvent(e);
}
 
Example 8
Source File: KeyboardFocusManagerPeerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public static boolean deliverFocus(Component lightweightChild,
                                   Component target,
                                   boolean temporary,
                                   boolean focusedWindowChangeAllowed,
                                   long time,
                                   CausedFocusEvent.Cause cause,
                                   Component currentFocusOwner) // provided by the descendant peers
{
    if (lightweightChild == null) {
        lightweightChild = target;
    }

    Component currentOwner = currentFocusOwner;
    if (currentOwner != null && currentOwner.getPeer() == null) {
        currentOwner = null;
    }
    if (currentOwner != null) {
        FocusEvent fl = new CausedFocusEvent(currentOwner, FocusEvent.FOCUS_LOST,
                                             false, lightweightChild, cause);

        if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
            focusLog.finer("Posting focus event: " + fl);
        }
        SunToolkit.postEvent(SunToolkit.targetToAppContext(currentOwner), fl);
    }

    FocusEvent fg = new CausedFocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED,
                                         false, currentOwner, cause);

    if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
        focusLog.finer("Posting focus event: " + fg);
    }
    SunToolkit.postEvent(SunToolkit.targetToAppContext(lightweightChild), fg);
    return true;
}
 
Example 9
Source File: WComponentPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("fallthrough")
public void handleEvent(AWTEvent e) {
    int id = e.getID();

    if ((e instanceof InputEvent) && !((InputEvent)e).isConsumed() &&
        ((Component)target).isEnabled())
    {
        if (e instanceof MouseEvent && !(e instanceof MouseWheelEvent)) {
            handleJavaMouseEvent((MouseEvent) e);
        } else if (e instanceof KeyEvent) {
            if (handleJavaKeyEvent((KeyEvent)e)) {
                return;
            }
        }
    }

    switch(id) {
        case PaintEvent.PAINT:
            // Got native painting
            paintPending = false;
            // Fallthrough to next statement
        case PaintEvent.UPDATE:
            // Skip all painting while layouting and all UPDATEs
            // while waiting for native paint
            if (!isLayouting && ! paintPending) {
                paintArea.paint(target,shouldClearRectBeforePaint());
            }
            return;
        case FocusEvent.FOCUS_LOST:
        case FocusEvent.FOCUS_GAINED:
            handleJavaFocusEvent((FocusEvent)e);
        default:
        break;
    }

    // Call the native code
    nativeHandleEvent(e);
}
 
Example 10
Source File: LWTextFieldPeer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Restoring native behavior. We should sets the selection range to zero,
 * when component lost its focus.
 *
 * @param e the focus event
 */
@Override
void handleJavaFocusEvent(final FocusEvent e) {
    if (e.getID() == FocusEvent.FOCUS_LOST) {
        // In order to de-select the selection
        setCaretPosition(0);
    }
    super.handleJavaFocusEvent(e);
}
 
Example 11
Source File: WComponentPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("fallthrough")
public void handleEvent(AWTEvent e) {
    int id = e.getID();

    if ((e instanceof InputEvent) && !((InputEvent)e).isConsumed() &&
        ((Component)target).isEnabled())
    {
        if (e instanceof MouseEvent && !(e instanceof MouseWheelEvent)) {
            handleJavaMouseEvent((MouseEvent) e);
        } else if (e instanceof KeyEvent) {
            if (handleJavaKeyEvent((KeyEvent)e)) {
                return;
            }
        }
    }

    switch(id) {
        case PaintEvent.PAINT:
            // Got native painting
            paintPending = false;
            // Fallthrough to next statement
        case PaintEvent.UPDATE:
            // Skip all painting while layouting and all UPDATEs
            // while waiting for native paint
            if (!isLayouting && ! paintPending) {
                paintArea.paint(target,shouldClearRectBeforePaint());
            }
            return;
        case FocusEvent.FOCUS_LOST:
        case FocusEvent.FOCUS_GAINED:
            handleJavaFocusEvent((FocusEvent)e);
        default:
        break;
    }

    // Call the native code
    nativeHandleEvent(e);
}
 
Example 12
Source File: KeyboardFocusManagerPeerImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public static boolean deliverFocus(Component lightweightChild,
                                   Component target,
                                   boolean temporary,
                                   boolean focusedWindowChangeAllowed,
                                   long time,
                                   FocusEvent.Cause cause,
                                   Component currentFocusOwner) // provided by the descendant peers
{
    if (lightweightChild == null) {
        lightweightChild = target;
    }

    Component currentOwner = currentFocusOwner;
    if (currentOwner != null && !currentOwner.isDisplayable()) {
        currentOwner = null;
    }
    if (currentOwner != null) {
        FocusEvent fl = new FocusEvent(currentOwner, FocusEvent.FOCUS_LOST,
                                             false, lightweightChild, cause);

        if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
            focusLog.finer("Posting focus event: " + fl);
        }
        SunToolkit.postEvent(SunToolkit.targetToAppContext(currentOwner), fl);
    }

    FocusEvent fg = new FocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED,
                                         false, currentOwner, cause);

    if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
        focusLog.finer("Posting focus event: " + fg);
    }
    SunToolkit.postEvent(SunToolkit.targetToAppContext(lightweightChild), fg);
    return true;
}
 
Example 13
Source File: KeyboardFocusManagerPeerImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public static boolean deliverFocus(Component lightweightChild,
                                   Component target,
                                   boolean temporary,
                                   boolean focusedWindowChangeAllowed,
                                   long time,
                                   CausedFocusEvent.Cause cause,
                                   Component currentFocusOwner) // provided by the descendant peers
{
    if (lightweightChild == null) {
        lightweightChild = target;
    }

    Component currentOwner = currentFocusOwner;
    if (currentOwner != null && currentOwner.getPeer() == null) {
        currentOwner = null;
    }
    if (currentOwner != null) {
        FocusEvent fl = new CausedFocusEvent(currentOwner, FocusEvent.FOCUS_LOST,
                                             false, lightweightChild, cause);

        if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
            focusLog.finer("Posting focus event: " + fl);
        }
        SunToolkit.postEvent(SunToolkit.targetToAppContext(currentOwner), fl);
    }

    FocusEvent fg = new CausedFocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED,
                                         false, currentOwner, cause);

    if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
        focusLog.finer("Posting focus event: " + fg);
    }
    SunToolkit.postEvent(SunToolkit.targetToAppContext(lightweightChild), fg);
    return true;
}
 
Example 14
Source File: KeyboardFocusManager.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
static AWTEvent retargetFocusEvent(AWTEvent event) {
    if (clearingCurrentLightweightRequests) {
        return event;
    }

    KeyboardFocusManager manager = getCurrentKeyboardFocusManager();
    if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
        if (event instanceof FocusEvent || event instanceof WindowEvent) {
            focusLog.finer(">>> {0}", String.valueOf(event));
        }
        if (focusLog.isLoggable(PlatformLogger.Level.FINER) && event instanceof KeyEvent) {
            focusLog.finer("    focus owner is {0}",
                           String.valueOf(manager.getGlobalFocusOwner()));
            focusLog.finer(">>> {0}", String.valueOf(event));
        }
    }

    synchronized(heavyweightRequests) {
        /*
         * This code handles FOCUS_LOST event which is generated by
         * DefaultKeyboardFocusManager for FOCUS_GAINED.
         *
         * This code based on knowledge of DefaultKeyboardFocusManager's
         * implementation and might be not applicable for another
         * KeyboardFocusManager.
         *
         * Fix for 4472032
         */
        if (newFocusOwner != null &&
            event.getID() == FocusEvent.FOCUS_LOST)
        {
            FocusEvent fe = (FocusEvent)event;

            if (manager.getGlobalFocusOwner() == fe.getComponent() &&
                fe.getOppositeComponent() == newFocusOwner)
            {
                newFocusOwner = null;
                return event;
            }
        }
    }

    processCurrentLightweightRequests();

    switch (event.getID()) {
        case FocusEvent.FOCUS_GAINED: {
            event = retargetFocusGained((FocusEvent)event);
            break;
        }
        case FocusEvent.FOCUS_LOST: {
            event = retargetFocusLost((FocusEvent)event);
            break;
        }
        default:
            /* do nothing */
    }
    return event;
}
 
Example 15
Source File: InputContext.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see java.awt.im.InputContext#dispatchEvent
 */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {

    if (event instanceof InputMethodEvent) {
        return;
    }

    // Ignore focus events that relate to the InputMethodWindow of this context.
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent)event).getOppositeComponent();
        if ((opposite != null) &&
            (getComponentWindow(opposite) instanceof InputMethodWindow) &&
            (opposite.getInputContext() == this)) {
            return;
        }
    }

    InputMethod inputMethod = getInputMethod();
    int id = event.getID();

    switch (id) {
    case FocusEvent.FOCUS_GAINED:
        focusGained((Component) event.getSource());
        break;

    case FocusEvent.FOCUS_LOST:
        focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
        break;

    case KeyEvent.KEY_PRESSED:
        if (checkInputMethodSelectionKey((KeyEvent)event)) {
            // pop up the input method selection menu
            InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
            break;
        }

        // fall through

    default:
        if ((inputMethod != null) && (event instanceof InputEvent)) {
            inputMethod.dispatchEvent(event);
        }
    }
}
 
Example 16
Source File: KeyboardFocusManager.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
static AWTEvent retargetFocusEvent(AWTEvent event) {
    if (clearingCurrentLightweightRequests) {
        return event;
    }

    KeyboardFocusManager manager = getCurrentKeyboardFocusManager();
    if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
        if (event instanceof FocusEvent || event instanceof WindowEvent) {
            focusLog.finer(">>> {0}", String.valueOf(event));
        }
        if (focusLog.isLoggable(PlatformLogger.Level.FINER) && event instanceof KeyEvent) {
            focusLog.finer("    focus owner is {0}",
                           String.valueOf(manager.getGlobalFocusOwner()));
            focusLog.finer(">>> {0}", String.valueOf(event));
        }
    }

    synchronized(heavyweightRequests) {
        /*
         * This code handles FOCUS_LOST event which is generated by
         * DefaultKeyboardFocusManager for FOCUS_GAINED.
         *
         * This code based on knowledge of DefaultKeyboardFocusManager's
         * implementation and might be not applicable for another
         * KeyboardFocusManager.
         *
         * Fix for 4472032
         */
        if (newFocusOwner != null &&
            event.getID() == FocusEvent.FOCUS_LOST)
        {
            FocusEvent fe = (FocusEvent)event;

            if (manager.getGlobalFocusOwner() == fe.getComponent() &&
                fe.getOppositeComponent() == newFocusOwner)
            {
                newFocusOwner = null;
                return event;
            }
        }
    }

    processCurrentLightweightRequests();

    switch (event.getID()) {
        case FocusEvent.FOCUS_GAINED: {
            event = retargetFocusGained((FocusEvent)event);
            break;
        }
        case FocusEvent.FOCUS_LOST: {
            event = retargetFocusLost((FocusEvent)event);
            break;
        }
        default:
            /* do nothing */
    }
    return event;
}
 
Example 17
Source File: KeyboardFocusManager.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
static AWTEvent retargetFocusEvent(AWTEvent event) {
    if (clearingCurrentLightweightRequests) {
        return event;
    }

    KeyboardFocusManager manager = getCurrentKeyboardFocusManager();
    if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
        if (event instanceof FocusEvent || event instanceof WindowEvent) {
            focusLog.finer(">>> {0}", String.valueOf(event));
        }
        if (focusLog.isLoggable(PlatformLogger.Level.FINER) && event instanceof KeyEvent) {
            focusLog.finer("    focus owner is {0}",
                           String.valueOf(manager.getGlobalFocusOwner()));
            focusLog.finer(">>> {0}", String.valueOf(event));
        }
    }

    synchronized(heavyweightRequests) {
        /*
         * This code handles FOCUS_LOST event which is generated by
         * DefaultKeyboardFocusManager for FOCUS_GAINED.
         *
         * This code based on knowledge of DefaultKeyboardFocusManager's
         * implementation and might be not applicable for another
         * KeyboardFocusManager.
         *
         * Fix for 4472032
         */
        if (newFocusOwner != null &&
            event.getID() == FocusEvent.FOCUS_LOST)
        {
            FocusEvent fe = (FocusEvent)event;

            if (manager.getGlobalFocusOwner() == fe.getComponent() &&
                fe.getOppositeComponent() == newFocusOwner)
            {
                newFocusOwner = null;
                return event;
            }
        }
    }

    processCurrentLightweightRequests();

    switch (event.getID()) {
        case FocusEvent.FOCUS_GAINED: {
            event = retargetFocusGained((FocusEvent)event);
            break;
        }
        case FocusEvent.FOCUS_LOST: {
            event = retargetFocusLost((FocusEvent)event);
            break;
        }
        default:
            /* do nothing */
    }
    return event;
}
 
Example 18
Source File: InputContext.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * @see java.awt.im.InputContext#dispatchEvent
 */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {

    if (event instanceof InputMethodEvent) {
        return;
    }

    // Ignore focus events that relate to the InputMethodWindow of this context.
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent)event).getOppositeComponent();
        if ((opposite != null) &&
            (getComponentWindow(opposite) instanceof InputMethodWindow) &&
            (opposite.getInputContext() == this)) {
            return;
        }
    }

    InputMethod inputMethod = getInputMethod();
    int id = event.getID();

    switch (id) {
    case FocusEvent.FOCUS_GAINED:
        focusGained((Component) event.getSource());
        break;

    case FocusEvent.FOCUS_LOST:
        focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
        break;

    case KeyEvent.KEY_PRESSED:
        if (checkInputMethodSelectionKey((KeyEvent)event)) {
            // pop up the input method selection menu
            InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
            break;
        }

        // fall through

    default:
        if ((inputMethod != null) && (event instanceof InputEvent)) {
            inputMethod.dispatchEvent(event);
        }
    }
}
 
Example 19
Source File: InputContext.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see java.awt.im.InputContext#dispatchEvent
 */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {

    if (event instanceof InputMethodEvent) {
        return;
    }

    // Ignore focus events that relate to the InputMethodWindow of this context.
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent)event).getOppositeComponent();
        if ((opposite != null) &&
            (getComponentWindow(opposite) instanceof InputMethodWindow) &&
            (opposite.getInputContext() == this)) {
            return;
        }
    }

    InputMethod inputMethod = getInputMethod();
    int id = event.getID();

    switch (id) {
    case FocusEvent.FOCUS_GAINED:
        focusGained((Component) event.getSource());
        break;

    case FocusEvent.FOCUS_LOST:
        focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
        break;

    case KeyEvent.KEY_PRESSED:
        if (checkInputMethodSelectionKey((KeyEvent)event)) {
            // pop up the input method selection menu
            InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource());
            break;
        }

        // fall through

    default:
        if ((inputMethod != null) && (event instanceof InputEvent)) {
            inputMethod.dispatchEvent(event);
        }
    }
}
 
Example 20
Source File: KeyboardFocusManager.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
static AWTEvent retargetFocusEvent(AWTEvent event) {
    if (clearingCurrentLightweightRequests) {
        return event;
    }

    KeyboardFocusManager manager = getCurrentKeyboardFocusManager();
    if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
        if (event instanceof FocusEvent || event instanceof WindowEvent) {
            focusLog.finer(">>> {0}", String.valueOf(event));
        }
        if (focusLog.isLoggable(PlatformLogger.Level.FINER) && event instanceof KeyEvent) {
            focusLog.finer("    focus owner is {0}",
                           String.valueOf(manager.getGlobalFocusOwner()));
            focusLog.finer(">>> {0}", String.valueOf(event));
        }
    }

    synchronized(heavyweightRequests) {
        /*
         * This code handles FOCUS_LOST event which is generated by
         * DefaultKeyboardFocusManager for FOCUS_GAINED.
         *
         * This code based on knowledge of DefaultKeyboardFocusManager's
         * implementation and might be not applicable for another
         * KeyboardFocusManager.
         *
         * Fix for 4472032
         */
        if (newFocusOwner != null &&
            event.getID() == FocusEvent.FOCUS_LOST)
        {
            FocusEvent fe = (FocusEvent)event;

            if (manager.getGlobalFocusOwner() == fe.getComponent() &&
                fe.getOppositeComponent() == newFocusOwner)
            {
                newFocusOwner = null;
                return event;
            }
        }
    }

    processCurrentLightweightRequests();

    switch (event.getID()) {
        case FocusEvent.FOCUS_GAINED: {
            event = retargetFocusGained((FocusEvent)event);
            break;
        }
        case FocusEvent.FOCUS_LOST: {
            event = retargetFocusLost((FocusEvent)event);
            break;
        }
        default:
            /* do nothing */
    }
    return event;
}