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

The following examples show how to use sun.awt.AppContext#get() . 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: ParserDelegator.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static synchronized DTD getDefaultDTD() {
    AppContext appContext = AppContext.getAppContext();

    DTD dtd = (DTD) appContext.get(DTD_KEY);

    if (dtd == null) {
        DTD _dtd = null;
        // (PENDING) Hate having to hard code!
        String nm = "html32";
        try {
            _dtd = DTD.getDTD(nm);
        } catch (IOException e) {
            // (PENDING) UGLY!
            System.out.println("Throw an exception: could not get default dtd: " + nm);
        }
        dtd = createDTD(_dtd, nm);

        appContext.put(DTD_KEY, dtd);
    }

    return dtd;
}
 
Example 2
Source File: ImageIcon.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: GTKStyle.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static Dimension[] getIconSizesMap() {
    AppContext appContext = AppContext.getAppContext();
    Dimension[] iconSizes = (Dimension[])appContext.get(ICON_SIZE_KEY);

    if (iconSizes == null) {
        iconSizes = new Dimension[7];
        iconSizes[0] = null;                  // GTK_ICON_SIZE_INVALID
        iconSizes[1] = new Dimension(16, 16); // GTK_ICON_SIZE_MENU
        iconSizes[2] = new Dimension(18, 18); // GTK_ICON_SIZE_SMALL_TOOLBAR
        iconSizes[3] = new Dimension(24, 24); // GTK_ICON_SIZE_LARGE_TOOLBAR
        iconSizes[4] = new Dimension(20, 20); // GTK_ICON_SIZE_BUTTON
        iconSizes[5] = new Dimension(32, 32); // GTK_ICON_SIZE_DND
        iconSizes[6] = new Dimension(48, 48); // GTK_ICON_SIZE_DIALOG
        appContext.put(ICON_SIZE_KEY, iconSizes);
    }
    return iconSizes;
}
 
Example 4
Source File: RepaintManager.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private static void scheduleDisplayChanges() {
    // To avoid threading problems, we notify each RepaintManager
    // on the thread it was created on.
    for (AppContext context : AppContext.getAppContexts()) {
        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()));
                }
            }
        }
    }
}
 
Example 5
Source File: JavaTargetLocator.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
private static Window[] getWindows(AppContext appContext) {
    synchronized (Window.class) {
        Window realCopy[];
        @SuppressWarnings("unchecked")
        Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>) appContext.get(Window.class);
        if (windowList != null) {
            int fullSize = windowList.size();
            int realSize = 0;
            Window fullCopy[] = new Window[fullSize];
            for (int i = 0; i < fullSize; i++) {
                Window w = windowList.get(i).get();
                if (w != null) {
                    fullCopy[realSize++] = w;
                }
            }
            if (fullSize != realSize) {
                realCopy = Arrays.copyOf(fullCopy, realSize);
            } else {
                realCopy = fullCopy;
            }
        } else {
            realCopy = new Window[0];
        }
        return realCopy;
    }
}
 
Example 6
Source File: ImageFetcher.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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;
    }
}
 
Example 7
Source File: Window.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static Window[] getWindows(AppContext appContext) {
    synchronized (Window.class) {
        Window realCopy[];
        @SuppressWarnings("unchecked")
        Vector<WeakReference<Window>> windowList =
            (Vector<WeakReference<Window>>)appContext.get(Window.class);
        if (windowList != null) {
            int fullSize = windowList.size();
            int realSize = 0;
            Window fullCopy[] = new Window[fullSize];
            for (int i = 0; i < fullSize; i++) {
                Window w = windowList.get(i).get();
                if (w != null) {
                    fullCopy[realSize++] = w;
                }
            }
            if (fullSize != realSize) {
                realCopy = Arrays.copyOf(fullCopy, realSize);
            } else {
                realCopy = fullCopy;
            }
        } else {
            realCopy = new Window[0];
        }
        return realCopy;
    }
}
 
Example 8
Source File: MotifLabelUI.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 9
Source File: ImageIO.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the <code>CacheInfo</code> object associated with this
 * <code>ThreadGroup</code>.
 */
private static synchronized CacheInfo getCacheInfo() {
    AppContext context = AppContext.getAppContext();
    CacheInfo info = (CacheInfo)context.get(CacheInfo.class);
    if (info == null) {
        info = new CacheInfo();
        context.put(CacheInfo.class, info);
    }
    return info;
}
 
Example 10
Source File: WindowsToggleButtonUI.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static ComponentUI createUI(JComponent b) {
    AppContext appContext = AppContext.getAppContext();
    WindowsToggleButtonUI windowsToggleButtonUI =
            (WindowsToggleButtonUI) appContext.get(WINDOWS_TOGGLE_BUTTON_UI_KEY);
    if (windowsToggleButtonUI == null) {
        windowsToggleButtonUI = new WindowsToggleButtonUI();
        appContext.put(WINDOWS_TOGGLE_BUTTON_UI_KEY, windowsToggleButtonUI);
    }
    return windowsToggleButtonUI;
}
 
Example 11
Source File: MetalLabelUI.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static ComponentUI createUI(JComponent c) {
    if (System.getSecurityManager() != null) {
        AppContext appContext = AppContext.getAppContext();
        MetalLabelUI safeMetalLabelUI =
                (MetalLabelUI) appContext.get(METAL_LABEL_UI_KEY);
        if (safeMetalLabelUI == null) {
            safeMetalLabelUI = new MetalLabelUI();
            appContext.put(METAL_LABEL_UI_KEY, safeMetalLabelUI);
        }
        return safeMetalLabelUI;
    }
    return metalLabelUI;
}
 
Example 12
Source File: AnimationController.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private static synchronized AnimationController getAnimationController() {
    AppContext appContext = AppContext.getAppContext();
    Object obj = appContext.get(ANIMATION_CONTROLLER_KEY);
    if (obj == null) {
        obj = new AnimationController();
        appContext.put(ANIMATION_CONTROLLER_KEY, obj);
    }
    return (AnimationController) obj;
}
 
Example 13
Source File: BasicCheckBoxUI.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static ComponentUI createUI(JComponent b) {
    AppContext appContext = AppContext.getAppContext();
    BasicCheckBoxUI checkboxUI =
            (BasicCheckBoxUI) appContext.get(BASIC_CHECK_BOX_UI_KEY);
    if (checkboxUI == null) {
        checkboxUI = new BasicCheckBoxUI();
        appContext.put(BASIC_CHECK_BOX_UI_KEY, checkboxUI);
    }
    return checkboxUI;
}
 
Example 14
Source File: BasicPopupMenuUI.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected void installListeners() {
    if (popupMenuListener == null) {
        popupMenuListener = new BasicPopupMenuListener();
    }
    popupMenu.addPopupMenuListener(popupMenuListener);

    if (menuKeyListener == null) {
        menuKeyListener = new BasicMenuKeyListener();
    }
    popupMenu.addMenuKeyListener(menuKeyListener);

    AppContext context = AppContext.getAppContext();
    synchronized (MOUSE_GRABBER_KEY) {
        MouseGrabber mouseGrabber = (MouseGrabber)context.get(
                                                 MOUSE_GRABBER_KEY);
        if (mouseGrabber == null) {
            mouseGrabber = new MouseGrabber();
            context.put(MOUSE_GRABBER_KEY, mouseGrabber);
        }
    }
    synchronized (MENU_KEYBOARD_HELPER_KEY) {
        MenuKeyboardHelper helper =
                (MenuKeyboardHelper)context.get(MENU_KEYBOARD_HELPER_KEY);
        if (helper == null) {
            helper = new MenuKeyboardHelper();
            context.put(MENU_KEYBOARD_HELPER_KEY, helper);
            MenuSelectionManager msm = MenuSelectionManager.defaultManager();
            msm.addChangeListener(helper);
        }
    }
}
 
Example 15
Source File: MotifButtonUI.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static ComponentUI createUI(JComponent c) {
    AppContext appContext = AppContext.getAppContext();
    MotifButtonUI motifButtonUI =
            (MotifButtonUI) appContext.get(MOTIF_BUTTON_UI_KEY);
    if (motifButtonUI == null) {
        motifButtonUI = new MotifButtonUI();
        appContext.put(MOTIF_BUTTON_UI_KEY, motifButtonUI);
    }
    return motifButtonUI;
}
 
Example 16
Source File: XDropTargetContextPeer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static XDropTargetContextPeer getPeer(AppContext appContext) {
    synchronized (_globalLock) {
        XDropTargetContextPeer peer =
            (XDropTargetContextPeer)appContext.get(DTCP_KEY);
        if (peer == null) {
            peer = new XDropTargetContextPeer();
            appContext.put(DTCP_KEY, peer);
        }

        return peer;
    }
}
 
Example 17
Source File: SunFontManager.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public boolean usingAlternateFontforJALocales() {
    if (!maybeMultiAppContext()) {
        return gAltJAFont;
    } else {
        AppContext appContext = AppContext.getAppContext();
        return appContext.get(altJAFontKey) == altJAFontKey;
    }
}
 
Example 18
Source File: Region.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
private static Map<String, Region> getUItoRegionMap() {
    AppContext context = AppContext.getAppContext();
    Map<String, Region> map = (Map<String, Region>) context.get(UI_TO_REGION_MAP_KEY);
    if (map == null) {
        map = new HashMap<String, Region>();
        map.put("ArrowButtonUI", ARROW_BUTTON);
        map.put("ButtonUI", BUTTON);
        map.put("CheckBoxUI", CHECK_BOX);
        map.put("CheckBoxMenuItemUI", CHECK_BOX_MENU_ITEM);
        map.put("ColorChooserUI", COLOR_CHOOSER);
        map.put("ComboBoxUI", COMBO_BOX);
        map.put("DesktopPaneUI", DESKTOP_PANE);
        map.put("DesktopIconUI", DESKTOP_ICON);
        map.put("EditorPaneUI", EDITOR_PANE);
        map.put("FileChooserUI", FILE_CHOOSER);
        map.put("FormattedTextFieldUI", FORMATTED_TEXT_FIELD);
        map.put("InternalFrameUI", INTERNAL_FRAME);
        map.put("InternalFrameTitlePaneUI", INTERNAL_FRAME_TITLE_PANE);
        map.put("LabelUI", LABEL);
        map.put("ListUI", LIST);
        map.put("MenuUI", MENU);
        map.put("MenuBarUI", MENU_BAR);
        map.put("MenuItemUI", MENU_ITEM);
        map.put("OptionPaneUI", OPTION_PANE);
        map.put("PanelUI", PANEL);
        map.put("PasswordFieldUI", PASSWORD_FIELD);
        map.put("PopupMenuUI", POPUP_MENU);
        map.put("PopupMenuSeparatorUI", POPUP_MENU_SEPARATOR);
        map.put("ProgressBarUI", PROGRESS_BAR);
        map.put("RadioButtonUI", RADIO_BUTTON);
        map.put("RadioButtonMenuItemUI", RADIO_BUTTON_MENU_ITEM);
        map.put("RootPaneUI", ROOT_PANE);
        map.put("ScrollBarUI", SCROLL_BAR);
        map.put("ScrollPaneUI", SCROLL_PANE);
        map.put("SeparatorUI", SEPARATOR);
        map.put("SliderUI", SLIDER);
        map.put("SpinnerUI", SPINNER);
        map.put("SplitPaneUI", SPLIT_PANE);
        map.put("TabbedPaneUI", TABBED_PANE);
        map.put("TableUI", TABLE);
        map.put("TableHeaderUI", TABLE_HEADER);
        map.put("TextAreaUI", TEXT_AREA);
        map.put("TextFieldUI", TEXT_FIELD);
        map.put("TextPaneUI", TEXT_PANE);
        map.put("ToggleButtonUI", TOGGLE_BUTTON);
        map.put("ToolBarUI", TOOL_BAR);
        map.put("ToolTipUI", TOOL_TIP);
        map.put("ToolBarSeparatorUI", TOOL_BAR_SEPARATOR);
        map.put("TreeUI", TREE);
        map.put("ViewportUI", VIEWPORT);
        context.put(UI_TO_REGION_MAP_KEY, map);
    }
    return map;
}
 
Example 19
Source File: IIORegistry.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the default <code>IIORegistry</code> instance used by
 * the Image I/O API.  This instance should be used for all
 * registry functions.
 *
 * <p> Each <code>ThreadGroup</code> will receive its own
 * instance; this allows different <code>Applet</code>s in the
 * same browser (for example) to each have their own registry.
 *
 * @return the default registry for the current
 * <code>ThreadGroup</code>.
 */
public static IIORegistry getDefaultInstance() {
    AppContext context = AppContext.getAppContext();
    IIORegistry registry =
        (IIORegistry)context.get(IIORegistry.class);
    if (registry == null) {
        // Create an instance for this AppContext
        registry = new IIORegistry();
        context.put(IIORegistry.class, registry);
    }
    return registry;
}
 
Example 20
Source File: DTD.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
private static Hashtable<String, DTD> getDtdHash() {
    AppContext appContext = AppContext.getAppContext();

    Hashtable<String, DTD> result = (Hashtable<String, DTD>) appContext.get(DTD_HASH_KEY);

    if (result == null) {
        result = new Hashtable<String, DTD>();

        appContext.put(DTD_HASH_KEY, result);
    }

    return result;
}