当前位置: 首页>>代码示例>>Java>>正文


Java AppContext类代码示例

本文整理汇总了Java中sun.awt.AppContext的典型用法代码示例。如果您正苦于以下问题:Java AppContext类的具体用法?Java AppContext怎么用?Java AppContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AppContext类属于sun.awt包,在下文中一共展示了AppContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: release

import sun.awt.AppContext; //导入依赖的package包/类
/**
 * Release this AppletClassLoader and its ThreadGroup/AppContext.
 * If nothing else has grabbed this AppletClassLoader, its ThreadGroup
 * and AppContext will be destroyed.
 *
 * Because this method may destroy the AppletClassLoader's ThreadGroup,
 * this method should NOT be called from within the AppletClassLoader's
 * ThreadGroup.
 *
 * Changed modifier to protected in order to be able to overwrite this
 * function in PluginClassLoader.java
 */
protected void release() {

    AppContext tempAppContext = null;

    synchronized(grabReleaseSynchronizer) {
        if (usageCount > 1)  {
            --usageCount;
        } else {
            synchronized(threadGroupSynchronizer) {
                tempAppContext = resetAppContext();
            }
        }
    }

    // Dispose appContext outside any sync block to
    // prevent potential deadlock.
    if (tempAppContext != null)  {
        try {
            tempAppContext.dispose(); // nuke the world!
        } catch (IllegalThreadStateException e) { }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:35,代码来源:AppletClassLoader.java

示例2: processDataConversionRequests

import sun.awt.AppContext; //导入依赖的package包/类
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();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:DataTransferer.java

示例3: remove

import sun.awt.AppContext; //导入依赖的package包/类
/**
 * Removes the specified <code>TrayIcon</code> from the
 * <code>SystemTray</code>.
 *
 * <p> All icons added by the application are automatically
 * removed from the <code>SystemTray</code> upon application exit
 * and also when the desktop system tray becomes unavailable.
 *
 * <p> If <code>trayIcon</code> is <code>null</code> or was not
 * added to the system tray, no exception is thrown and no action
 * is performed.
 *
 * @param trayIcon the <code>TrayIcon</code> to be removed
 * @see #add(TrayIcon)
 * @see TrayIcon
 */
public void remove(TrayIcon trayIcon) {
    if (trayIcon == null) {
        return;
    }
    TrayIcon[] oldArray = null, newArray = null;
    synchronized (this) {
        oldArray = systemTray.getTrayIcons();
        Vector<TrayIcon> icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
        // TrayIcon with no peer is not contained in the array.
        if (icons == null || !icons.remove(trayIcon)) {
            return;
        }
        trayIcon.removeNotify();
        newArray = systemTray.getTrayIcons();
    }
    firePropertyChange("trayIcons", oldArray, newArray);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:SystemTray.java

示例4: scheduleDisplayChanges

import sun.awt.AppContext; //导入依赖的package包/类
private void scheduleDisplayChanges() {
    // To avoid threading problems, we notify each RepaintManager
    // on the thread it was created on.
    for (Object c : AppContext.getAppContexts()) {
        AppContext context = (AppContext) c;
        synchronized(context) {
            if (!context.isDisposed()) {
                EventQueue eventQueue = (EventQueue)context.get(
                    AppContext.EVENT_QUEUE_KEY);
                if (eventQueue != null) {
                    eventQueue.postEvent(new InvocationEvent(
                        Toolkit.getDefaultToolkit(),
                        new DisplayChangedRunnable()));
                }
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:RepaintManager.java

示例5: getCreatedFonts

import sun.awt.AppContext; //导入依赖的package包/类
public Font[] getCreatedFonts() {

        Hashtable<String,Font2D> nameTable;
        if (fontsAreRegistered) {
            nameTable = createdByFullName;
        } else if (fontsAreRegisteredPerAppContext) {
            AppContext appContext = AppContext.getAppContext();
            nameTable =
                (Hashtable<String,Font2D>)appContext.get(regFullNameKey);
        } else {
            return null;
        }

        Locale l = getSystemStartupLocale();
        synchronized (nameTable) {
            Font[] fonts = new Font[nameTable.size()];
            int i=0;
            for (Font2D font2D : nameTable.values()) {
                fonts[i++] = new Font(font2D.getFontName(l), Font.PLAIN, 1);
            }
            return fonts;
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:SunFontManager.java

示例6: lostOwnershipNow

import sun.awt.AppContext; //导入依赖的package包/类
protected void lostOwnershipNow(final AppContext disposedContext) {
    final SunClipboard sunClipboard = SunClipboard.this;
    ClipboardOwner owner = null;
    Transferable contents = null;

    synchronized (sunClipboard) {
        final AppContext context = sunClipboard.contentsContext;

        if (context == null) {
            return;
        }

        if (disposedContext == null || context == disposedContext) {
            owner = sunClipboard.owner;
            contents = sunClipboard.contents;
            sunClipboard.contentsContext = null;
            sunClipboard.owner = null;
            sunClipboard.contents = null;
            sunClipboard.clearNativeContext();
            context.removePropertyChangeListener
                    (AppContext.DISPOSED_PROPERTY_NAME, sunClipboard);
        } else {
            return;
        }
    }
    if (owner != null) {
        owner.lostOwnership(sunClipboard, contents);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:SunClipboard.java

示例7: createUI

import sun.awt.AppContext; //导入依赖的package包/类
public static ComponentUI createUI(JComponent c) {
    AppContext appContext = AppContext.getAppContext();
    MotifCheckBoxUI motifCheckBoxUI =
            (MotifCheckBoxUI) appContext.get(MOTIF_CHECK_BOX_UI_KEY);
    if (motifCheckBoxUI == null) {
        motifCheckBoxUI = new MotifCheckBoxUI();
        appContext.put(MOTIF_CHECK_BOX_UI_KEY, motifCheckBoxUI);
    }
    return motifCheckBoxUI;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:MotifCheckBoxUI.java

示例8: windowsSettingChange

import sun.awt.AppContext; //导入依赖的package包/类
private void windowsSettingChange() {
    // JDK-8039383: Have to update the value of XPSTYLE_THEME_ACTIVE property
    // as soon as possible to prevent NPE and other errors because theme data
    // has become unavailable.
    final Map<String, Object> props = getWProps();
    if (props == null) {
        // props has not been initialized, so we have nothing to update
        return;
    }

    updateXPStyleEnabled(props.get(XPSTYLE_THEME_ACTIVE));

    if (AppContext.getAppContext() == null) {
        // We cannot post the update to any EventQueue. Listeners will
        // be called on EDTs by DesktopPropertyChangeSupport
        updateProperties(props);
    } else {
        // Cannot update on Toolkit thread.
        // DesktopPropertyChangeSupport will call listeners on Toolkit
        // thread if it has AppContext (standalone mode)
        EventQueue.invokeLater(() -> updateProperties(props));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:WToolkit.java

示例9: createUI

import sun.awt.AppContext; //导入依赖的package包/类
public static ComponentUI createUI(JComponent c) {
    AppContext appContext = AppContext.getAppContext();
    MotifLabelUI motifLabelUI =
            (MotifLabelUI) appContext.get(MOTIF_LABEL_UI_KEY);
    if (motifLabelUI == null) {
        motifLabelUI = new MotifLabelUI();
        appContext.put(MOTIF_LABEL_UI_KEY, motifLabelUI);
    }
    return motifLabelUI;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:MotifLabelUI.java

示例10: getStyleSheet

import sun.awt.AppContext; //导入依赖的package包/类
/**
 * Get the set of styles currently being used to render the
 * HTML elements.  By default the resource specified by
 * DEFAULT_CSS gets loaded, and is shared by all HTMLEditorKit
 * instances.
 *
 * @return the StyleSheet
 */
public StyleSheet getStyleSheet() {
    AppContext appContext = AppContext.getAppContext();
    StyleSheet defaultStyles = (StyleSheet) appContext.get(DEFAULT_STYLES_KEY);

    if (defaultStyles == null) {
        defaultStyles = new StyleSheet();
        appContext.put(DEFAULT_STYLES_KEY, defaultStyles);
        try {
            InputStream is = HTMLEditorKit.getResourceAsStream(DEFAULT_CSS);
            Reader r = new BufferedReader(
                    new InputStreamReader(is, "ISO-8859-1"));
            defaultStyles.loadRules(r, null);
            r.close();
        } catch (Throwable e) {
            // on error we simply have no styles... the html
            // will look mighty wrong but still function.
        }
    }
    return defaultStyles;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:HTMLEditorKit.java

示例11: dispatch

import sun.awt.AppContext; //导入依赖的package包/类
void dispatch(final _NativeEvent event, final Object... args) {
    // grab a local ref to the listeners and its contexts as an array of the map's entries
    final ArrayList<Map.Entry<L, AppContext>> localEntries;
    synchronized (this) {
        if (listenerToAppContext.size() == 0) {
            return;
        }
        localEntries = new ArrayList<Map.Entry<L, AppContext>>(listenerToAppContext.size());
        localEntries.addAll(listenerToAppContext.entrySet());
    }

    for (final Map.Entry<L, AppContext> e : localEntries) {
        final L listener = e.getKey();
        final AppContext listenerContext = e.getValue();
        SunToolkit.invokeLaterOnAppContext(listenerContext, new Runnable() {
            public void run() {
                performOnListener(listener, event);
            }
        });
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:_AppEventHandler.java

示例12: thirdValidate

import sun.awt.AppContext; //导入依赖的package包/类
public void thirdValidate() throws Exception {
    Field key = BasicPopupMenuUI.class.getDeclaredField("MOUSE_GRABBER_KEY");
    key.setAccessible(true);

    Object grabber = AppContext.getAppContext().get(key.get(null));
    if (grabber == null) {
        throw new Exception("cannot find a mouse grabber in app's context");
    }

    Field field = grabber.getClass().getDeclaredField("grabbedWindow");
    field.setAccessible(true);

    Object window = field.get(grabber);
    if (window != null) {
        throw new Exception("interaction with GNOME is crippled");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:bug6495920.java

示例13: getFetcherInfo

import sun.awt.AppContext; //导入依赖的package包/类
static FetcherInfo getFetcherInfo() {
    AppContext appContext = AppContext.getAppContext();
    synchronized(appContext) {
        FetcherInfo info = (FetcherInfo)appContext.get(FETCHER_INFO_KEY);
        if (info == null) {
            info = new FetcherInfo();
            appContext.put(FETCHER_INFO_KEY, info);
        }
        return info;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:ImageFetcher.java

示例14: getTracker

import sun.awt.AppContext; //导入依赖的package包/类
/**
 * Returns the MediaTracker for the current AppContext, creating a new
 * MediaTracker if necessary.
 */
private MediaTracker getTracker() {
    Object trackerObj;
    AppContext ac = AppContext.getAppContext();
    // Opt: Only synchronize if trackerObj comes back null?
    // If null, synchronize, re-check for null, and put new tracker
    synchronized(ac) {
        trackerObj = ac.get(TRACKER_KEY);
        if (trackerObj == null) {
            Component comp = new Component() {};
            trackerObj = new MediaTracker(comp);
            ac.put(TRACKER_KEY, trackerObj);
        }
    }
    return (MediaTracker) trackerObj;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:ImageIcon.java

示例15: removeFlavorListener

import sun.awt.AppContext; //导入依赖的package包/类
public synchronized void removeFlavorListener(FlavorListener listener) {
    if (listener == null) {
        return;
    }
    AppContext appContext = AppContext.getAppContext();
    EventListenerAggregate contextFlavorListeners = (EventListenerAggregate)
            appContext.get(CLIPBOARD_FLAVOR_LISTENER_KEY);
    if (contextFlavorListeners == null){
        //else we throw NullPointerException, but it is forbidden
        return;
    }
    if (contextFlavorListeners.remove(listener) &&
            --numberOfFlavorListeners == 0) {
        unregisterClipboardViewerChecked();
        currentDataFlavors = null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:SunClipboard.java


注:本文中的sun.awt.AppContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。