本文整理汇总了Java中sun.awt.AppContext.getAppContext方法的典型用法代码示例。如果您正苦于以下问题:Java AppContext.getAppContext方法的具体用法?Java AppContext.getAppContext怎么用?Java AppContext.getAppContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.awt.AppContext
的用法示例。
在下文中一共展示了AppContext.getAppContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: createUI
import sun.awt.AppContext; //导入方法依赖的package包/类
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;
}
示例3: getDefaultQueue
import sun.awt.AppContext; //导入方法依赖的package包/类
/**
* Fetch the default layout queue.
*/
public static LayoutQueue getDefaultQueue() {
AppContext ac = AppContext.getAppContext();
synchronized (DEFAULT_QUEUE) {
LayoutQueue defaultQueue = (LayoutQueue) ac.get(DEFAULT_QUEUE);
if (defaultQueue == null) {
defaultQueue = new LayoutQueue();
ac.put(DEFAULT_QUEUE, defaultQueue);
}
return defaultQueue;
}
}
示例4: getDoSubmit
import sun.awt.AppContext; //导入方法依赖的package包/类
private static AccumulativeRunnable<Runnable> getDoSubmit() {
synchronized (DO_SUBMIT_KEY) {
final AppContext appContext = AppContext.getAppContext();
Object doSubmit = appContext.get(DO_SUBMIT_KEY);
if (doSubmit == null) {
doSubmit = new DoSubmitAccumulativeRunnable();
appContext.put(DO_SUBMIT_KEY, doSubmit);
}
@SuppressWarnings("unchecked")
AccumulativeRunnable<Runnable> tmp = (AccumulativeRunnable<Runnable>) doSubmit;
return tmp;
}
}
示例5: 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;
}
}
示例6: createUI
import sun.awt.AppContext; //导入方法依赖的package包/类
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;
}
示例7: preferLocaleFonts
import sun.awt.AppContext; //导入方法依赖的package包/类
public synchronized void preferLocaleFonts() {
if (FontUtilities.isLogging()) {
FontUtilities.getLogger().info("Entered preferLocaleFonts().");
}
/* Test if re-ordering will have any effect */
if (!FontConfiguration.willReorderForStartupLocale()) {
return;
}
if (!maybeMultiAppContext()) {
if (gLocalePref == true) {
return;
}
gLocalePref = true;
createCompositeFonts(fontNameCache, gLocalePref, gPropPref);
_usingAlternateComposites = true;
} else {
AppContext appContext = AppContext.getAppContext();
if (appContext.get(localeFontKey) == localeFontKey) {
return;
}
appContext.put(localeFontKey, localeFontKey);
boolean acPropPref =
appContext.get(proportionalFontKey) == proportionalFontKey;
ConcurrentHashMap<String, Font2D>
altNameCache = new ConcurrentHashMap<String, Font2D> ();
/* If there is an existing hashtable, we can drop it. */
appContext.put(CompositeFont.class, altNameCache);
_usingPerAppContextComposites = true;
createCompositeFonts(altNameCache, true, acPropPref);
}
}
示例8: getDefaultFlavorMap
import sun.awt.AppContext; //导入方法依赖的package包/类
/**
* 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;
}
示例9: sendMessage
import sun.awt.AppContext; //导入方法依赖的package包/类
/**
* Sends a synthetic AWTEvent to a Component. If the Component is in
* the current AppContext, then the event is immediately dispatched.
* If the Component is in a different AppContext, then the event is
* posted to the other AppContext's EventQueue, and this method blocks
* until the event is handled or target AppContext is disposed.
* Returns true if successfully dispatched event, false if failed
* to dispatch.
*/
static boolean sendMessage(Component target, AWTEvent e) {
e.isPosted = true;
AppContext myAppContext = AppContext.getAppContext();
final AppContext targetAppContext = target.appContext;
final SentEvent se =
new DefaultKeyboardFocusManagerSentEvent(e, myAppContext);
if (myAppContext == targetAppContext) {
se.dispatch();
} else {
if (targetAppContext.isDisposed()) {
return false;
}
SunToolkit.postEvent(targetAppContext, se);
if (EventQueue.isDispatchThread()) {
EventDispatchThread edt = (EventDispatchThread)
Thread.currentThread();
edt.pumpEvents(SentEvent.ID, new Conditional() {
public boolean evaluate() {
return !se.dispatched && !targetAppContext.isDisposed();
}
});
} else {
synchronized (se) {
while (!se.dispatched && !targetAppContext.isDisposed()) {
try {
se.wait(1000);
} catch (InterruptedException ie) {
break;
}
}
}
}
}
return se.dispatched;
}
示例10: createUI
import sun.awt.AppContext; //导入方法依赖的package包/类
public static ComponentUI createUI(JComponent c) {
AppContext appContext = AppContext.getAppContext();
BasicButtonUI buttonUI =
(BasicButtonUI) appContext.get(BASIC_BUTTON_UI_KEY);
if (buttonUI == null) {
buttonUI = new BasicButtonUI();
appContext.put(BASIC_BUTTON_UI_KEY, buttonUI);
}
return buttonUI;
}
示例11: createUI
import sun.awt.AppContext; //导入方法依赖的package包/类
public static ComponentUI createUI(JComponent c) {
if (System.getSecurityManager() != null) {
AppContext appContext = AppContext.getAppContext();
BasicLabelUI safeBasicLabelUI =
(BasicLabelUI) appContext.get(BASIC_LABEL_UI_KEY);
if (safeBasicLabelUI == null) {
safeBasicLabelUI = new BasicLabelUI();
appContext.put(BASIC_LABEL_UI_KEY, safeBasicLabelUI);
}
return safeBasicLabelUI;
}
return labelUI;
}
示例12: createUI
import sun.awt.AppContext; //导入方法依赖的package包/类
/**
* Returns an instance of {@code BasicLabelUI}.
*
* @param c a component
* @return an instance of {@code BasicLabelUI}
*/
public static ComponentUI createUI(JComponent c) {
if (System.getSecurityManager() != null) {
AppContext appContext = AppContext.getAppContext();
BasicLabelUI safeBasicLabelUI =
(BasicLabelUI) appContext.get(BASIC_LABEL_UI_KEY);
if (safeBasicLabelUI == null) {
safeBasicLabelUI = new BasicLabelUI();
appContext.put(BASIC_LABEL_UI_KEY, safeBasicLabelUI);
}
return safeBasicLabelUI;
}
return labelUI;
}
示例13: createUI
import sun.awt.AppContext; //导入方法依赖的package包/类
/**
* Returns an instance of {@code MetalLabelUI}.
*
* @param c a component
* @return an instance of {@code MetalLabelUI}
*/
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;
}
示例14: createUI
import sun.awt.AppContext; //导入方法依赖的package包/类
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;
}
示例15: getFocusedWindow
import sun.awt.AppContext; //导入方法依赖的package包/类
/**
* Returns the focused Window, if the focused Window is in the same context
* as the calling thread. The focused Window is the Window that is or
* contains the focus owner.
*
* @return the focused Window, or null if the focused Window is not a
* member of the calling thread's context
* @see #getGlobalFocusedWindow
* @see #setGlobalFocusedWindow
*/
public Window getFocusedWindow() {
synchronized (KeyboardFocusManager.class) {
if (focusedWindow == null) {
return null;
}
return (focusedWindow.appContext == AppContext.getAppContext())
? focusedWindow
: null;
}
}