Java Code Examples for sun.awt.AppContext#remove()

The following examples show how to use sun.awt.AppContext#remove() . 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: DataTransferer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void processDataConversionRequests() {
    if (EventQueue.isDispatchThread()) {
        AppContext appContext = AppContext.getAppContext();
        getToolkitThreadBlockedHandler().lock();
        try {
            Runnable dataConverter =
                (Runnable)appContext.get(DATA_CONVERTER_KEY);
            if (dataConverter != null) {
                dataConverter.run();
                appContext.remove(DATA_CONVERTER_KEY);
            }
        } finally {
            getToolkitThreadBlockedHandler().unlock();
        }
    }
}
 
Example 2
Source File: DataTransferer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void processDataConversionRequests() {
    if (EventQueue.isDispatchThread()) {
        AppContext appContext = AppContext.getAppContext();
        getToolkitThreadBlockedHandler().lock();
        try {
            Runnable dataConverter =
                (Runnable)appContext.get(DATA_CONVERTER_KEY);
            if (dataConverter != null) {
                dataConverter.run();
                appContext.remove(DATA_CONVERTER_KEY);
            }
        } finally {
            getToolkitThreadBlockedHandler().unlock();
        }
    }
}
 
Example 3
Source File: DataTransferer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void processDataConversionRequests() {
    if (EventQueue.isDispatchThread()) {
        AppContext appContext = AppContext.getAppContext();
        getToolkitThreadBlockedHandler().lock();
        try {
            Runnable dataConverter =
                (Runnable)appContext.get(DATA_CONVERTER_KEY);
            if (dataConverter != null) {
                dataConverter.run();
                appContext.remove(DATA_CONVERTER_KEY);
            }
        } finally {
            getToolkitThreadBlockedHandler().unlock();
        }
    }
}
 
Example 4
Source File: DataTransferer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void processDataConversionRequests() {
    if (EventQueue.isDispatchThread()) {
        AppContext appContext = AppContext.getAppContext();
        getToolkitThreadBlockedHandler().lock();
        try {
            Runnable dataConverter =
                (Runnable)appContext.get(DATA_CONVERTER_KEY);
            if (dataConverter != null) {
                dataConverter.run();
                appContext.remove(DATA_CONVERTER_KEY);
            }
        } finally {
            getToolkitThreadBlockedHandler().unlock();
        }
    }
}
 
Example 5
Source File: DataTransferer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void processDataConversionRequests() {
    if (EventQueue.isDispatchThread()) {
        AppContext appContext = AppContext.getAppContext();
        getToolkitThreadBlockedHandler().lock();
        try {
            Runnable dataConverter =
                (Runnable)appContext.get(DATA_CONVERTER_KEY);
            if (dataConverter != null) {
                dataConverter.run();
                appContext.remove(DATA_CONVERTER_KEY);
            }
        } finally {
            getToolkitThreadBlockedHandler().unlock();
        }
    }
}
 
Example 6
Source File: DataTransferer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void processDataConversionRequests() {
    if (EventQueue.isDispatchThread()) {
        AppContext appContext = AppContext.getAppContext();
        getToolkitThreadBlockedHandler().lock();
        try {
            Runnable dataConverter =
                (Runnable)appContext.get(DATA_CONVERTER_KEY);
            if (dataConverter != null) {
                dataConverter.run();
                appContext.remove(DATA_CONVERTER_KEY);
            }
        } finally {
            getToolkitThreadBlockedHandler().unlock();
        }
    }
}
 
Example 7
Source File: DataTransferer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void processDataConversionRequests() {
    if (EventQueue.isDispatchThread()) {
        AppContext appContext = AppContext.getAppContext();
        getToolkitThreadBlockedHandler().lock();
        try {
            Runnable dataConverter =
                (Runnable)appContext.get(DATA_CONVERTER_KEY);
            if (dataConverter != null) {
                dataConverter.run();
                appContext.remove(DATA_CONVERTER_KEY);
            }
        } finally {
            getToolkitThreadBlockedHandler().unlock();
        }
    }
}
 
Example 8
Source File: DataTransferer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void processDataConversionRequests() {
    if (EventQueue.isDispatchThread()) {
        AppContext appContext = AppContext.getAppContext();
        getToolkitThreadBlockedHandler().lock();
        try {
            Runnable dataConverter =
                (Runnable)appContext.get(DATA_CONVERTER_KEY);
            if (dataConverter != null) {
                dataConverter.run();
                appContext.remove(DATA_CONVERTER_KEY);
            }
        } finally {
            getToolkitThreadBlockedHandler().unlock();
        }
    }
}
 
Example 9
Source File: DataTransferer.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public void processDataConversionRequests() {
    if (EventQueue.isDispatchThread()) {
        AppContext appContext = AppContext.getAppContext();
        getToolkitThreadBlockedHandler().lock();
        try {
            Runnable dataConverter =
                (Runnable)appContext.get(DATA_CONVERTER_KEY);
            if (dataConverter != null) {
                dataConverter.run();
                appContext.remove(DATA_CONVERTER_KEY);
            }
        } finally {
            getToolkitThreadBlockedHandler().unlock();
        }
    }
}
 
Example 10
Source File: KeyboardFocusManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the current KeyboardFocusManager instance for the calling thread's
 * context. If null is specified, then the current KeyboardFocusManager
 * is replaced with a new instance of DefaultKeyboardFocusManager.
 * <p>
 * If a SecurityManager is installed, the calling thread must be granted
 * the AWTPermission "replaceKeyboardFocusManager" in order to replace the
 * the current KeyboardFocusManager. If this permission is not granted,
 * this method will throw a SecurityException, and the current
 * KeyboardFocusManager will be unchanged.
 *
 * @param newManager the new KeyboardFocusManager for this thread's context
 * @see #getCurrentKeyboardFocusManager
 * @see DefaultKeyboardFocusManager
 * @throws SecurityException if the calling thread does not have permission
 *         to replace the current KeyboardFocusManager
 */
public static void setCurrentKeyboardFocusManager(
    KeyboardFocusManager newManager) throws SecurityException
{
    checkReplaceKFMPermission();

    KeyboardFocusManager oldManager = null;

    synchronized (KeyboardFocusManager.class) {
        AppContext appcontext = AppContext.getAppContext();

        if (newManager != null) {
            oldManager = getCurrentKeyboardFocusManager(appcontext);

            appcontext.put(KeyboardFocusManager.class, newManager);
        } else {
            oldManager = getCurrentKeyboardFocusManager(appcontext);
            appcontext.remove(KeyboardFocusManager.class);
        }
    }

    if (oldManager != null) {
        oldManager.firePropertyChange("managingFocus",
                                      Boolean.TRUE,
                                      Boolean.FALSE);
    }
    if (newManager != null) {
        newManager.firePropertyChange("managingFocus",
                                      Boolean.FALSE,
                                      Boolean.TRUE);
    }
}
 
Example 11
Source File: KeyboardFocusManager.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the current KeyboardFocusManager instance for the calling thread's
 * context. If null is specified, then the current KeyboardFocusManager
 * is replaced with a new instance of DefaultKeyboardFocusManager.
 * <p>
 * If a SecurityManager is installed, the calling thread must be granted
 * the AWTPermission "replaceKeyboardFocusManager" in order to replace the
 * the current KeyboardFocusManager. If this permission is not granted,
 * this method will throw a SecurityException, and the current
 * KeyboardFocusManager will be unchanged.
 *
 * @param newManager the new KeyboardFocusManager for this thread's context
 * @see #getCurrentKeyboardFocusManager
 * @see DefaultKeyboardFocusManager
 * @throws SecurityException if the calling thread does not have permission
 *         to replace the current KeyboardFocusManager
 */
public static void setCurrentKeyboardFocusManager(
    KeyboardFocusManager newManager) throws SecurityException
{
    checkReplaceKFMPermission();

    KeyboardFocusManager oldManager = null;

    synchronized (KeyboardFocusManager.class) {
        AppContext appcontext = AppContext.getAppContext();

        if (newManager != null) {
            oldManager = getCurrentKeyboardFocusManager(appcontext);

            appcontext.put(KeyboardFocusManager.class, newManager);
        } else {
            oldManager = getCurrentKeyboardFocusManager(appcontext);
            appcontext.remove(KeyboardFocusManager.class);
        }
    }

    if (oldManager != null) {
        oldManager.firePropertyChange("managingFocus",
                                      Boolean.TRUE,
                                      Boolean.FALSE);
    }
    if (newManager != null) {
        newManager.firePropertyChange("managingFocus",
                                      Boolean.FALSE,
                                      Boolean.TRUE);
    }
}
 
Example 12
Source File: KeyboardFocusManager.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the current KeyboardFocusManager instance for the calling thread's
 * context. If null is specified, then the current KeyboardFocusManager
 * is replaced with a new instance of DefaultKeyboardFocusManager.
 * <p>
 * If a SecurityManager is installed, the calling thread must be granted
 * the AWTPermission "replaceKeyboardFocusManager" in order to replace the
 * the current KeyboardFocusManager. If this permission is not granted,
 * this method will throw a SecurityException, and the current
 * KeyboardFocusManager will be unchanged.
 *
 * @param newManager the new KeyboardFocusManager for this thread's context
 * @see #getCurrentKeyboardFocusManager
 * @see DefaultKeyboardFocusManager
 * @throws SecurityException if the calling thread does not have permission
 *         to replace the current KeyboardFocusManager
 */
public static void setCurrentKeyboardFocusManager(
    KeyboardFocusManager newManager) throws SecurityException
{
    checkReplaceKFMPermission();

    KeyboardFocusManager oldManager = null;

    synchronized (KeyboardFocusManager.class) {
        AppContext appcontext = AppContext.getAppContext();

        if (newManager != null) {
            oldManager = getCurrentKeyboardFocusManager(appcontext);

            appcontext.put(KeyboardFocusManager.class, newManager);
        } else {
            oldManager = getCurrentKeyboardFocusManager(appcontext);
            appcontext.remove(KeyboardFocusManager.class);
        }
    }

    if (oldManager != null) {
        oldManager.firePropertyChange("managingFocus",
                                      Boolean.TRUE,
                                      Boolean.FALSE);
    }
    if (newManager != null) {
        newManager.firePropertyChange("managingFocus",
                                      Boolean.FALSE,
                                      Boolean.TRUE);
    }
}
 
Example 13
Source File: KeyboardFocusManager.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the current KeyboardFocusManager instance for the calling thread's
 * context. If null is specified, then the current KeyboardFocusManager
 * is replaced with a new instance of DefaultKeyboardFocusManager.
 * <p>
 * If a SecurityManager is installed, the calling thread must be granted
 * the AWTPermission "replaceKeyboardFocusManager" in order to replace the
 * the current KeyboardFocusManager. If this permission is not granted,
 * this method will throw a SecurityException, and the current
 * KeyboardFocusManager will be unchanged.
 *
 * @param newManager the new KeyboardFocusManager for this thread's context
 * @see #getCurrentKeyboardFocusManager
 * @see DefaultKeyboardFocusManager
 * @throws SecurityException if the calling thread does not have permission
 *         to replace the current KeyboardFocusManager
 */
public static void setCurrentKeyboardFocusManager(
    KeyboardFocusManager newManager) throws SecurityException
{
    checkReplaceKFMPermission();

    KeyboardFocusManager oldManager = null;

    synchronized (KeyboardFocusManager.class) {
        AppContext appcontext = AppContext.getAppContext();

        if (newManager != null) {
            oldManager = getCurrentKeyboardFocusManager(appcontext);

            appcontext.put(KeyboardFocusManager.class, newManager);
        } else {
            oldManager = getCurrentKeyboardFocusManager(appcontext);
            appcontext.remove(KeyboardFocusManager.class);
        }
    }

    if (oldManager != null) {
        oldManager.firePropertyChange("managingFocus",
                                      Boolean.TRUE,
                                      Boolean.FALSE);
    }
    if (newManager != null) {
        newManager.firePropertyChange("managingFocus",
                                      Boolean.FALSE,
                                      Boolean.TRUE);
    }
}
 
Example 14
Source File: KeyboardFocusManager.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the current KeyboardFocusManager instance for the calling thread's
 * context. If null is specified, then the current KeyboardFocusManager
 * is replaced with a new instance of DefaultKeyboardFocusManager.
 * <p>
 * If a SecurityManager is installed, the calling thread must be granted
 * the AWTPermission "replaceKeyboardFocusManager" in order to replace the
 * the current KeyboardFocusManager. If this permission is not granted,
 * this method will throw a SecurityException, and the current
 * KeyboardFocusManager will be unchanged.
 *
 * @param newManager the new KeyboardFocusManager for this thread's context
 * @see #getCurrentKeyboardFocusManager
 * @see DefaultKeyboardFocusManager
 * @throws SecurityException if the calling thread does not have permission
 *         to replace the current KeyboardFocusManager
 */
public static void setCurrentKeyboardFocusManager(
    KeyboardFocusManager newManager) throws SecurityException
{
    checkReplaceKFMPermission();

    KeyboardFocusManager oldManager = null;

    synchronized (KeyboardFocusManager.class) {
        AppContext appcontext = AppContext.getAppContext();

        if (newManager != null) {
            oldManager = getCurrentKeyboardFocusManager(appcontext);

            appcontext.put(KeyboardFocusManager.class, newManager);
        } else {
            oldManager = getCurrentKeyboardFocusManager(appcontext);
            appcontext.remove(KeyboardFocusManager.class);
        }
    }

    if (oldManager != null) {
        oldManager.firePropertyChange("managingFocus",
                                      Boolean.TRUE,
                                      Boolean.FALSE);
    }
    if (newManager != null) {
        newManager.firePropertyChange("managingFocus",
                                      Boolean.FALSE,
                                      Boolean.TRUE);
    }
}
 
Example 15
Source File: KeyboardFocusManager.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the current KeyboardFocusManager instance for the calling thread's
 * context. If null is specified, then the current KeyboardFocusManager
 * is replaced with a new instance of DefaultKeyboardFocusManager.
 * <p>
 * If a SecurityManager is installed, the calling thread must be granted
 * the AWTPermission "replaceKeyboardFocusManager" in order to replace the
 * the current KeyboardFocusManager. If this permission is not granted,
 * this method will throw a SecurityException, and the current
 * KeyboardFocusManager will be unchanged.
 *
 * @param newManager the new KeyboardFocusManager for this thread's context
 * @see #getCurrentKeyboardFocusManager
 * @see DefaultKeyboardFocusManager
 * @throws SecurityException if the calling thread does not have permission
 *         to replace the current KeyboardFocusManager
 */
public static void setCurrentKeyboardFocusManager(
    KeyboardFocusManager newManager) throws SecurityException
{
    checkReplaceKFMPermission();

    KeyboardFocusManager oldManager = null;

    synchronized (KeyboardFocusManager.class) {
        AppContext appcontext = AppContext.getAppContext();

        if (newManager != null) {
            oldManager = getCurrentKeyboardFocusManager(appcontext);

            appcontext.put(KeyboardFocusManager.class, newManager);
        } else {
            oldManager = getCurrentKeyboardFocusManager(appcontext);
            appcontext.remove(KeyboardFocusManager.class);
        }
    }

    if (oldManager != null) {
        oldManager.firePropertyChange("managingFocus",
                                      Boolean.TRUE,
                                      Boolean.FALSE);
    }
    if (newManager != null) {
        newManager.firePropertyChange("managingFocus",
                                      Boolean.FALSE,
                                      Boolean.TRUE);
    }
}
 
Example 16
Source File: KeyboardFocusManager.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the current KeyboardFocusManager instance for the calling thread's
 * context. If null is specified, then the current KeyboardFocusManager
 * is replaced with a new instance of DefaultKeyboardFocusManager.
 * <p>
 * If a SecurityManager is installed, the calling thread must be granted
 * the AWTPermission "replaceKeyboardFocusManager" in order to replace the
 * the current KeyboardFocusManager. If this permission is not granted,
 * this method will throw a SecurityException, and the current
 * KeyboardFocusManager will be unchanged.
 *
 * @param newManager the new KeyboardFocusManager for this thread's context
 * @see #getCurrentKeyboardFocusManager
 * @see DefaultKeyboardFocusManager
 * @throws SecurityException if the calling thread does not have permission
 *         to replace the current KeyboardFocusManager
 */
public static void setCurrentKeyboardFocusManager(
    KeyboardFocusManager newManager) throws SecurityException
{
    checkReplaceKFMPermission();

    KeyboardFocusManager oldManager = null;

    synchronized (KeyboardFocusManager.class) {
        AppContext appcontext = AppContext.getAppContext();

        if (newManager != null) {
            oldManager = getCurrentKeyboardFocusManager(appcontext);

            appcontext.put(KeyboardFocusManager.class, newManager);
        } else {
            oldManager = getCurrentKeyboardFocusManager(appcontext);
            appcontext.remove(KeyboardFocusManager.class);
        }
    }

    if (oldManager != null) {
        oldManager.firePropertyChange("managingFocus",
                                      Boolean.TRUE,
                                      Boolean.FALSE);
    }
    if (newManager != null) {
        newManager.firePropertyChange("managingFocus",
                                      Boolean.FALSE,
                                      Boolean.TRUE);
    }
}
 
Example 17
Source File: KeyboardFocusManager.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Sets the current KeyboardFocusManager instance for the calling thread's
 * context. If null is specified, then the current KeyboardFocusManager
 * is replaced with a new instance of DefaultKeyboardFocusManager.
 * <p>
 * If a SecurityManager is installed, the calling thread must be granted
 * the AWTPermission "replaceKeyboardFocusManager" in order to replace the
 * the current KeyboardFocusManager. If this permission is not granted,
 * this method will throw a SecurityException, and the current
 * KeyboardFocusManager will be unchanged.
 *
 * @param newManager the new KeyboardFocusManager for this thread's context
 * @see #getCurrentKeyboardFocusManager
 * @see DefaultKeyboardFocusManager
 * @throws SecurityException if the calling thread does not have permission
 *         to replace the current KeyboardFocusManager
 */
public static void setCurrentKeyboardFocusManager(
    KeyboardFocusManager newManager) throws SecurityException
{
    checkReplaceKFMPermission();

    KeyboardFocusManager oldManager = null;

    synchronized (KeyboardFocusManager.class) {
        AppContext appcontext = AppContext.getAppContext();

        if (newManager != null) {
            oldManager = getCurrentKeyboardFocusManager(appcontext);

            appcontext.put(KeyboardFocusManager.class, newManager);
        } else {
            oldManager = getCurrentKeyboardFocusManager(appcontext);
            appcontext.remove(KeyboardFocusManager.class);
        }
    }

    if (oldManager != null) {
        oldManager.firePropertyChange("managingFocus",
                                      Boolean.TRUE,
                                      Boolean.FALSE);
    }
    if (newManager != null) {
        newManager.firePropertyChange("managingFocus",
                                      Boolean.FALSE,
                                      Boolean.TRUE);
    }
}
 
Example 18
Source File: KeyboardFocusManager.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the current KeyboardFocusManager instance for the calling thread's
 * context. If null is specified, then the current KeyboardFocusManager
 * is replaced with a new instance of DefaultKeyboardFocusManager.
 * <p>
 * If a SecurityManager is installed, the calling thread must be granted
 * the AWTPermission "replaceKeyboardFocusManager" in order to replace the
 * the current KeyboardFocusManager. If this permission is not granted,
 * this method will throw a SecurityException, and the current
 * KeyboardFocusManager will be unchanged.
 *
 * @param newManager the new KeyboardFocusManager for this thread's context
 * @see #getCurrentKeyboardFocusManager
 * @see DefaultKeyboardFocusManager
 * @throws SecurityException if the calling thread does not have permission
 *         to replace the current KeyboardFocusManager
 */
public static void setCurrentKeyboardFocusManager(
    KeyboardFocusManager newManager) throws SecurityException
{
    checkReplaceKFMPermission();

    KeyboardFocusManager oldManager = null;

    synchronized (KeyboardFocusManager.class) {
        AppContext appcontext = AppContext.getAppContext();

        if (newManager != null) {
            oldManager = getCurrentKeyboardFocusManager(appcontext);

            appcontext.put(KeyboardFocusManager.class, newManager);
        } else {
            oldManager = getCurrentKeyboardFocusManager(appcontext);
            appcontext.remove(KeyboardFocusManager.class);
        }
    }

    if (oldManager != null) {
        oldManager.firePropertyChange("managingFocus",
                                      Boolean.TRUE,
                                      Boolean.FALSE);
    }
    if (newManager != null) {
        newManager.firePropertyChange("managingFocus",
                                      Boolean.FALSE,
                                      Boolean.TRUE);
    }
}
 
Example 19
Source File: KeyboardFocusManager.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the current KeyboardFocusManager instance for the calling thread's
 * context. If null is specified, then the current KeyboardFocusManager
 * is replaced with a new instance of DefaultKeyboardFocusManager.
 * <p>
 * If a SecurityManager is installed, the calling thread must be granted
 * the AWTPermission "replaceKeyboardFocusManager" in order to replace the
 * the current KeyboardFocusManager. If this permission is not granted,
 * this method will throw a SecurityException, and the current
 * KeyboardFocusManager will be unchanged.
 *
 * @param newManager the new KeyboardFocusManager for this thread's context
 * @see #getCurrentKeyboardFocusManager
 * @see DefaultKeyboardFocusManager
 * @throws SecurityException if the calling thread does not have permission
 *         to replace the current KeyboardFocusManager
 */
public static void setCurrentKeyboardFocusManager(
    KeyboardFocusManager newManager) throws SecurityException
{
    checkReplaceKFMPermission();

    KeyboardFocusManager oldManager = null;

    synchronized (KeyboardFocusManager.class) {
        AppContext appcontext = AppContext.getAppContext();

        if (newManager != null) {
            oldManager = getCurrentKeyboardFocusManager(appcontext);

            appcontext.put(KeyboardFocusManager.class, newManager);
        } else {
            oldManager = getCurrentKeyboardFocusManager(appcontext);
            appcontext.remove(KeyboardFocusManager.class);
        }
    }

    if (oldManager != null) {
        oldManager.firePropertyChange("managingFocus",
                                      Boolean.TRUE,
                                      Boolean.FALSE);
    }
    if (newManager != null) {
        newManager.firePropertyChange("managingFocus",
                                      Boolean.FALSE,
                                      Boolean.TRUE);
    }
}
 
Example 20
Source File: KeyboardFocusManager.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the current KeyboardFocusManager instance for the calling thread's
 * context. If null is specified, then the current KeyboardFocusManager
 * is replaced with a new instance of DefaultKeyboardFocusManager.
 * <p>
 * If a SecurityManager is installed, the calling thread must be granted
 * the AWTPermission "replaceKeyboardFocusManager" in order to replace the
 * the current KeyboardFocusManager. If this permission is not granted,
 * this method will throw a SecurityException, and the current
 * KeyboardFocusManager will be unchanged.
 *
 * @param newManager the new KeyboardFocusManager for this thread's context
 * @see #getCurrentKeyboardFocusManager
 * @see DefaultKeyboardFocusManager
 * @throws SecurityException if the calling thread does not have permission
 *         to replace the current KeyboardFocusManager
 */
public static void setCurrentKeyboardFocusManager(
    KeyboardFocusManager newManager) throws SecurityException
{
    checkReplaceKFMPermission();

    KeyboardFocusManager oldManager = null;

    synchronized (KeyboardFocusManager.class) {
        AppContext appcontext = AppContext.getAppContext();

        if (newManager != null) {
            oldManager = getCurrentKeyboardFocusManager(appcontext);

            appcontext.put(KeyboardFocusManager.class, newManager);
        } else {
            oldManager = getCurrentKeyboardFocusManager(appcontext);
            appcontext.remove(KeyboardFocusManager.class);
        }
    }

    if (oldManager != null) {
        oldManager.firePropertyChange("managingFocus",
                                      Boolean.TRUE,
                                      Boolean.FALSE);
    }
    if (newManager != null) {
        newManager.firePropertyChange("managingFocus",
                                      Boolean.FALSE,
                                      Boolean.TRUE);
    }
}