use of sun.awt.AppContext in project jdk8u_jdk by JetBrains.
the class ImageIcon method getTracker.
/**
* Returns the MediaTracker for the current AppContext, creating a new
* MediaTracker if necessary.
*/
private MediaTracker getTracker() {
Object trackerObj;
AppContext ac = AppContext.getAppContext();
// 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;
}
use of sun.awt.AppContext in project jdk8u_jdk by JetBrains.
the class BasicRadioButtonUI method createUI.
// ********************************
// Create PLAF
// ********************************
/**
* Returns an instance of {@code BasicRadioButtonUI}.
*
* @param b a component
* @return an instance of {@code BasicRadioButtonUI}
*/
public static ComponentUI createUI(JComponent b) {
AppContext appContext = AppContext.getAppContext();
BasicRadioButtonUI radioButtonUI = (BasicRadioButtonUI) appContext.get(BASIC_RADIO_BUTTON_UI_KEY);
if (radioButtonUI == null) {
radioButtonUI = new BasicRadioButtonUI();
appContext.put(BASIC_RADIO_BUTTON_UI_KEY, radioButtonUI);
}
return radioButtonUI;
}
use of sun.awt.AppContext in project jdk8u_jdk by JetBrains.
the class BasicPopupMenuUI method installListeners.
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);
}
}
}
use of sun.awt.AppContext in project jdk8u_jdk by JetBrains.
the class BasicLookAndFeel method uninitialize.
/**
* {@inheritDoc}
*/
public void uninitialize() {
AppContext context = AppContext.getAppContext();
synchronized (BasicPopupMenuUI.MOUSE_GRABBER_KEY) {
Object grabber = context.get(BasicPopupMenuUI.MOUSE_GRABBER_KEY);
if (grabber != null) {
((BasicPopupMenuUI.MouseGrabber) grabber).uninstall();
}
}
synchronized (BasicPopupMenuUI.MENU_KEYBOARD_HELPER_KEY) {
Object helper = context.get(BasicPopupMenuUI.MENU_KEYBOARD_HELPER_KEY);
if (helper != null) {
((BasicPopupMenuUI.MenuKeyboardHelper) helper).uninstall();
}
}
if (invocator != null) {
AccessController.doPrivileged(invocator);
invocator = null;
}
if (disposer != null) {
// Note that we're likely calling removePropertyChangeListener()
// during the course of AppContext.firePropertyChange().
// However, EventListenerAggreggate has code to safely modify
// the list under such circumstances.
context.removePropertyChangeListener(AppContext.GUI_DISPOSED, disposer);
disposer = null;
}
}
use of sun.awt.AppContext in project jdk8u_jdk by JetBrains.
the class DataTransferer method processDataConversionRequests.
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();
}
}
}
Aggregations