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

The following examples show how to use sun.awt.AppContext#put() . 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: ImageIcon.java    From JDKSourceCode1.8 with MIT License 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 2
Source File: SunFontManager.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public synchronized void useAlternateFontforJALocales() {
    if (FontUtilities.isLogging()) {
        FontUtilities.getLogger()
            .info("Entered useAlternateFontforJALocales().");
    }
    if (!FontUtilities.isWindows) {
        return;
    }

    if (!maybeMultiAppContext()) {
        gAltJAFont = true;
    } else {
        AppContext appContext = AppContext.getAppContext();
        appContext.put(altJAFontKey, altJAFontKey);
    }
}
 
Example 3
Source File: MenuSelectionManager.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the default menu selection manager.
 *
 * @return a MenuSelectionManager object
 */
public static MenuSelectionManager defaultManager() {
    synchronized (MENU_SELECTION_MANAGER_KEY) {
        AppContext context = AppContext.getAppContext();
        MenuSelectionManager msm = (MenuSelectionManager)context.get(
                                             MENU_SELECTION_MANAGER_KEY);
        if (msm == null) {
            msm = new MenuSelectionManager();
            context.put(MENU_SELECTION_MANAGER_KEY, msm);

            // installing additional listener if found in the AppContext
            Object o = context.get(SwingUtilities2.MENU_SELECTION_MANAGER_LISTENER_KEY);
            if (o != null && o instanceof ChangeListener) {
                msm.addChangeListener((ChangeListener) o);
            }
        }

        return msm;
    }
}
 
Example 4
Source File: AnimationController.java    From jdk8u60 with GNU General Public License v2.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 5
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 6
Source File: WindowsButtonUI.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static ComponentUI createUI(JComponent c) {
    AppContext appContext = AppContext.getAppContext();
    WindowsButtonUI windowsButtonUI =
            (WindowsButtonUI) appContext.get(WINDOWS_BUTTON_UI_KEY);
    if (windowsButtonUI == null) {
        windowsButtonUI = new WindowsButtonUI();
        appContext.put(WINDOWS_BUTTON_UI_KEY, windowsButtonUI);
    }
    return windowsButtonUI;
}
 
Example 7
Source File: SystemFlavorMap.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the default FlavorMap for this thread's ClassLoader.
 */
public static FlavorMap getDefaultFlavorMap() {
    AppContext context = AppContext.getAppContext();
    FlavorMap fm = (FlavorMap) context.get(FLAVOR_MAP_KEY);
    if (fm == null) {
        fm = new SystemFlavorMap();
        context.put(FLAVOR_MAP_KEY, fm);
    }
    return fm;
}
 
Example 8
Source File: BasicCheckBoxUI.java    From jdk8u-dev-jdk 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 9
Source File: WindowsToggleButtonUI.java    From jdk8u_jdk 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 10
Source File: ImageIO.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the {@code CacheInfo} object associated with this
 * {@code ThreadGroup}.
 */
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 11
Source File: BasicPopupMenuUI.java    From openjdk-8 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 12
Source File: BasicToggleButtonUI.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static ComponentUI createUI(JComponent b) {
    AppContext appContext = AppContext.getAppContext();
    BasicToggleButtonUI toggleButtonUI =
            (BasicToggleButtonUI) appContext.get(BASIC_TOGGLE_BUTTON_UI_KEY);
    if (toggleButtonUI == null) {
        toggleButtonUI = new BasicToggleButtonUI();
        appContext.put(BASIC_TOGGLE_BUTTON_UI_KEY, toggleButtonUI);
    }
    return toggleButtonUI;
}
 
Example 13
Source File: MenuSelectionManager.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the default menu selection manager.
 *
 * @return a MenuSelectionManager object
 */
public static MenuSelectionManager defaultManager() {
    synchronized (MENU_SELECTION_MANAGER_KEY) {
        AppContext context = AppContext.getAppContext();
        MenuSelectionManager msm = (MenuSelectionManager)context.get(
                                             MENU_SELECTION_MANAGER_KEY);
        if (msm == null) {
            msm = new MenuSelectionManager();
            context.put(MENU_SELECTION_MANAGER_KEY, msm);
        }

        return msm;
    }
}
 
Example 14
Source File: WindowsRadioButtonUI.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static ComponentUI createUI(JComponent c) {
    AppContext appContext = AppContext.getAppContext();
    WindowsRadioButtonUI windowsRadioButtonUI =
            (WindowsRadioButtonUI) appContext.get(WINDOWS_RADIO_BUTTON_UI_KEY);
    if (windowsRadioButtonUI == null) {
        windowsRadioButtonUI = new WindowsRadioButtonUI();
        appContext.put(WINDOWS_RADIO_BUTTON_UI_KEY, windowsRadioButtonUI);
    }
    return windowsRadioButtonUI;
}
 
Example 15
Source File: MotifToggleButtonUI.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public static ComponentUI createUI(JComponent b) {
    AppContext appContext = AppContext.getAppContext();
    MotifToggleButtonUI motifToggleButtonUI =
            (MotifToggleButtonUI) appContext.get(MOTIF_TOGGLE_BUTTON_UI_KEY);
    if (motifToggleButtonUI == null) {
        motifToggleButtonUI = new MotifToggleButtonUI();
        appContext.put(MOTIF_TOGGLE_BUTTON_UI_KEY, motifToggleButtonUI);
    }
    return motifToggleButtonUI;
}
 
Example 16
Source File: ImageFetcher.java    From openjdk-jdk9 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 17
Source File: MetalCheckBoxUI.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static ComponentUI createUI(JComponent b) {
    AppContext appContext = AppContext.getAppContext();
    MetalCheckBoxUI checkboxUI =
            (MetalCheckBoxUI) appContext.get(METAL_CHECK_BOX_UI_KEY);
    if (checkboxUI == null) {
        checkboxUI = new MetalCheckBoxUI();
        appContext.put(METAL_CHECK_BOX_UI_KEY, checkboxUI);
    }
    return checkboxUI;
}
 
Example 18
Source File: MotifRadioButtonUI.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static ComponentUI createUI(JComponent c) {
    AppContext appContext = AppContext.getAppContext();
    MotifRadioButtonUI motifRadioButtonUI =
            (MotifRadioButtonUI) appContext.get(MOTIF_RADIO_BUTTON_UI_KEY);
    if (motifRadioButtonUI == null) {
        motifRadioButtonUI = new MotifRadioButtonUI();
        appContext.put(MOTIF_RADIO_BUTTON_UI_KEY, motifRadioButtonUI);
    }
    return motifRadioButtonUI;
}
 
Example 19
Source File: WindowsLabelUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static ComponentUI createUI(JComponent c) {
    AppContext appContext = AppContext.getAppContext();
    WindowsLabelUI windowsLabelUI =
            (WindowsLabelUI) appContext.get(WINDOWS_LABEL_UI_KEY);
    if (windowsLabelUI == null) {
        windowsLabelUI = new WindowsLabelUI();
        appContext.put(WINDOWS_LABEL_UI_KEY, windowsLabelUI);
    }
    return windowsLabelUI;
}
 
Example 20
Source File: Region.java    From openjdk-jdk8u-backup with GNU General Public License v2.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;
}