sun.awt.AppContext Java Examples
The following examples show how to use
sun.awt.AppContext.
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: JTextComponent.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static HashMap<String,Keymap> getKeymapTable() { synchronized (KEYMAP_TABLE) { AppContext appContext = AppContext.getAppContext(); HashMap<String,Keymap> keymapTable = (HashMap<String,Keymap>)appContext.get(KEYMAP_TABLE); if (keymapTable == null) { keymapTable = new HashMap<String,Keymap>(17); appContext.put(KEYMAP_TABLE, keymapTable); //initialize default keymap Keymap binding = addKeymap(DEFAULT_KEYMAP, null); binding.setDefaultAction(new DefaultEditorKit.DefaultKeyTypedAction()); } return keymapTable; } }
Example #2
Source File: _AppEventHandler.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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); } }); } }
Example #3
Source File: MenuSelectionManager.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * 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: SystemTray.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * 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); }
Example #5
Source File: SunClipboard.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private synchronized void initContext() { final AppContext context = AppContext.getAppContext(); if (contentsContext != context) { // Need to synchronize on the AppContext to guarantee that it cannot // be disposed after the check, but before the listener is added. synchronized (context) { if (context.isDisposed()) { throw new IllegalStateException("Can't set contents from disposed AppContext"); } context.addPropertyChangeListener (AppContext.DISPOSED_PROPERTY_NAME, this); } if (contentsContext != null) { contentsContext.removePropertyChangeListener (AppContext.DISPOSED_PROPERTY_NAME, this); } contentsContext = context; } }
Example #6
Source File: SunClipboard.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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(); currentFormats = null; } }
Example #7
Source File: RepaintManager.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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 #8
Source File: DefaultMetalTheme.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Returns the ideal font style for the font identified by key. */ static int getDefaultFontStyle(int key) { if (key != WINDOW_TITLE_FONT) { Object boldMetal = null; if (AppContext.getAppContext().get( SwingUtilities2.LAF_STATE_KEY) != null) { // Only access the boldMetal key if a look and feel has // been loaded, otherwise we'll trigger loading the look // and feel. boldMetal = UIManager.get("swing.boldMetal"); } if (boldMetal != null) { if (Boolean.FALSE.equals(boldMetal)) { return Font.PLAIN; } } else if (PLAIN_FONTS) { return Font.PLAIN; } } return fontStyles[key]; }
Example #9
Source File: SystemTray.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * 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); }
Example #10
Source File: DefaultMetalTheme.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Returns the ideal font style for the font identified by key. */ static int getDefaultFontStyle(int key) { if (key != WINDOW_TITLE_FONT) { Object boldMetal = null; if (AppContext.getAppContext().get( SwingUtilities2.LAF_STATE_KEY) != null) { // Only access the boldMetal key if a look and feel has // been loaded, otherwise we'll trigger loading the look // and feel. boldMetal = UIManager.get("swing.boldMetal"); } if (boldMetal != null) { if (Boolean.FALSE.equals(boldMetal)) { return Font.PLAIN; } } else if (PLAIN_FONTS) { return Font.PLAIN; } } return fontStyles[key]; }
Example #11
Source File: _AppEventHandler.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
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); } }); } }
Example #12
Source File: GTKStyle.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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 #13
Source File: GTKStyle.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
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 #14
Source File: BasicLookAndFeel.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * {@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; } }
Example #15
Source File: SunClipboard.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public void propertyChange(PropertyChangeEvent evt) { if (AppContext.DISPOSED_PROPERTY_NAME.equals(evt.getPropertyName()) && Boolean.TRUE.equals(evt.getNewValue())) { final AppContext disposedContext = (AppContext)evt.getSource(); lostOwnershipLater(disposedContext); } }
Example #16
Source File: BasicLabelUI.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #17
Source File: SwingUtilities3.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Registers delegate RepaintManager for {@code JComponent}. */ public static void setDelegateRepaintManager(JComponent component, RepaintManager repaintManager) { /* setting up flag in AppContext to speed up lookups in case * there are no delegate RepaintManagers used. */ AppContext.getAppContext().put(DELEGATE_REPAINT_MANAGER_KEY, Boolean.TRUE); component.putClientProperty(DELEGATE_REPAINT_MANAGER_KEY, repaintManager); }
Example #18
Source File: AWTKeyStroke.java From Bytecoder with Apache License 2.0 | 5 votes |
private static synchronized AWTKeyStroke getCachedStroke (char keyChar, int keyCode, int modifiers, boolean onKeyRelease) { @SuppressWarnings("unchecked") Map<AWTKeyStroke, AWTKeyStroke> cache = (Map)AppContext.getAppContext().get(APP_CONTEXT_CACHE_KEY); AWTKeyStroke cacheKey = (AWTKeyStroke)AppContext.getAppContext().get(APP_CONTEXT_KEYSTROKE_KEY); if (cache == null) { cache = new HashMap<>(); AppContext.getAppContext().put(APP_CONTEXT_CACHE_KEY, cache); } if (cacheKey == null) { cacheKey = SwingAccessor.getKeyStrokeAccessor().create(); AppContext.getAppContext().put(APP_CONTEXT_KEYSTROKE_KEY, cacheKey); } cacheKey.keyChar = keyChar; cacheKey.keyCode = keyCode; cacheKey.modifiers = mapNewModifiers(mapOldModifiers(modifiers)); cacheKey.onKeyRelease = onKeyRelease; AWTKeyStroke stroke = cache.get(cacheKey); if (stroke == null) { stroke = cacheKey; cache.put(stroke, stroke); AppContext.getAppContext().remove(APP_CONTEXT_KEYSTROKE_KEY); } return stroke; }
Example #19
Source File: InputMethodEvent.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Get the most recent event time in the {@code EventQueue} which the {@code source} * belongs to. * * @param source the source of the event * @exception IllegalArgumentException if source is null. * @return most recent event time in the {@code EventQueue} */ private static long getMostRecentEventTimeForSource(Object source) { if (source == null) { // throw the IllegalArgumentException to conform to EventObject spec throw new IllegalArgumentException("null source"); } AppContext appContext = SunToolkit.targetToAppContext(source); EventQueue eventQueue = SunToolkit.getSystemEventQueueImplPP(appContext); return AWTAccessor.getEventQueueAccessor().getMostRecentEventTime(eventQueue); }
Example #20
Source File: DesktopDatatransferServiceImpl.java From Bytecoder with Apache License 2.0 | 5 votes |
@Override public FlavorMap getFlavorMap(Supplier<FlavorMap> supplier) { AppContext context = AppContext.getAppContext(); FlavorMap fm = (FlavorMap) context.get(FLAVOR_MAP_KEY); if (fm == null) { fm = supplier.get(); context.put(FLAVOR_MAP_KEY, fm); } return fm; }
Example #21
Source File: WindowsCheckBoxUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static ComponentUI createUI(JComponent c) { AppContext appContext = AppContext.getAppContext(); WindowsCheckBoxUI windowsCheckBoxUI = (WindowsCheckBoxUI) appContext.get(WINDOWS_CHECK_BOX_UI_KEY); if (windowsCheckBoxUI == null) { windowsCheckBoxUI = new WindowsCheckBoxUI(); appContext.put(WINDOWS_CHECK_BOX_UI_KEY, windowsCheckBoxUI); } return windowsCheckBoxUI; }
Example #22
Source File: TrayIcon.java From JDKSourceCode1.8 with MIT License | 5 votes |
private TrayIcon() throws UnsupportedOperationException, HeadlessException, SecurityException { SystemTray.checkSystemTrayAllowed(); if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException(); } if (!SystemTray.isSupported()) { throw new UnsupportedOperationException(); } SunToolkit.insertTargetMapping(this, AppContext.getAppContext()); }
Example #23
Source File: MetalToggleButtonUI.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Constructs the {@code MetalToogleButtonUI}. * * @param b a component * @return the {@code MetalToogleButtonUI}. */ public static ComponentUI createUI(JComponent b) { AppContext appContext = AppContext.getAppContext(); MetalToggleButtonUI metalToggleButtonUI = (MetalToggleButtonUI) appContext.get(METAL_TOGGLE_BUTTON_UI_KEY); if (metalToggleButtonUI == null) { metalToggleButtonUI = new MetalToggleButtonUI(); appContext.put(METAL_TOGGLE_BUTTON_UI_KEY, metalToggleButtonUI); } return metalToggleButtonUI; }
Example #24
Source File: Toolkit.java From jdk-1.7-annotated with Apache License 2.0 | 5 votes |
@Override public synchronized void removePropertyChangeListener( String propertyName, PropertyChangeListener listener) { PropertyChangeSupport pcs = (PropertyChangeSupport) AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); if (null != pcs) { pcs.removePropertyChangeListener(propertyName, listener); } }
Example #25
Source File: ImageFetcher.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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 #26
Source File: MotifButtonUI.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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 #27
Source File: KeyboardFocusManager.java From Java8CN with Apache License 2.0 | 5 votes |
/** * 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; } }
Example #28
Source File: MotifCheckBoxUI.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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; }
Example #29
Source File: DTD.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static Hashtable<String, DTD> getDtdHash() { AppContext appContext = AppContext.getAppContext(); @SuppressWarnings("unchecked") 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; }
Example #30
Source File: MetalCheckBoxUI.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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; }