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: 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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
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 #14
Source File: SunClipboard.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Checks change of the {@code DataFlavor}s and, if necessary, * posts notifications on {@code FlavorEvent}s to the * AppContexts' EDTs. * The parameter {@code formats} is null iff we have just * failed to get formats available on the clipboard. * * @param formats data formats that have just been retrieved from * this clipboard */ protected final void checkChange(final long[] formats) { if (Arrays.equals(formats, currentFormats)) { // we've been able to successfully get available on the clipboard // DataFlavors this and previous time and they are coincident; // don't notify return; } currentFormats = formats; for (final AppContext appContext : AppContext.getAppContexts()) { if (appContext == null || appContext.isDisposed()) { continue; } Set<FlavorListener> flavorListeners = getFlavorListeners(appContext); if (flavorListeners != null) { for (FlavorListener listener : flavorListeners) { if (listener != null) { PeerEvent peerEvent = new PeerEvent(this, () -> listener.flavorsChanged(new FlavorEvent(SunClipboard.this)), PeerEvent.PRIORITY_EVENT); SunToolkit.postEvent(appContext, peerEvent); } } } } }
Example #15
Source File: BasicToggleButtonUI.java From Java8CN with Apache License 2.0 | 5 votes |
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 #16
Source File: AppletSecurity.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Tests if a client can get access to the AWT event queue. * <p> * This method calls <code>checkPermission</code> with the * <code>AWTPermission("accessEventQueue")</code> permission. * * @since JDK1.1 * @exception SecurityException if the caller does not have * permission to access the AWT event queue. */ public void checkAwtEventQueueAccess() { AppContext appContext = AppContext.getAppContext(); AppletClassLoader appletClassLoader = currentAppletClassLoader(); if (AppContext.isMainContext(appContext) && (appletClassLoader != null)) { // If we're about to allow access to the main EventQueue, // and anything untrusted is on the class context stack, // disallow access. super.checkPermission(SecurityConstants.AWT.CHECK_AWT_EVENTQUEUE_PERMISSION); } }
Example #17
Source File: SentEvent.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
SentEvent(AWTEvent nested, AppContext toNotify) { super((nested != null) ? nested.getSource() : Toolkit.getDefaultToolkit(), ID); this.nested = nested; this.toNotify = toNotify; }
Example #18
Source File: BasicTextUI.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static DragListener getDragListener() { synchronized(DragListener.class) { DragListener listener = (DragListener)AppContext.getAppContext(). get(DragListener.class); if (listener == null) { listener = new DragListener(); AppContext.getAppContext().put(DragListener.class, listener); } return listener; } }
Example #19
Source File: ImageFetcher.java From openjdk-jdk9 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 #20
Source File: TrayIcon.java From dragonwell8_jdk with GNU General Public License v2.0 | 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 #21
Source File: WindowsLabelUI.java From hottub with GNU General Public License v2.0 | 5 votes |
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 #22
Source File: Toolkit.java From jdk8u-jdk with GNU General Public License v2.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 #23
Source File: MetalLabelUI.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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 #24
Source File: SystemFlavorMap.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * 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 #25
Source File: BasicPopupMenuUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
void uninstall() { synchronized (MOUSE_GRABBER_KEY) { MenuSelectionManager.defaultManager().removeChangeListener(this); ungrabWindow(); AppContext.getAppContext().remove(MOUSE_GRABBER_KEY); } }
Example #26
Source File: Toolkit.java From jdk8u_jdk with GNU General Public License v2.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 #27
Source File: ExecutableInputMethodManager.java From hottub with GNU General Public License v2.0 | 5 votes |
private void showInputMethodMenuOnRequesterEDT(Component requester) throws InterruptedException, InvocationTargetException { if (requester == null){ return; } class AWTInvocationLock {} Object lock = new AWTInvocationLock(); InvocationEvent event = new InvocationEvent(requester, new Runnable() { public void run() { showInputMethodMenu(); } }, lock, true); AppContext requesterAppContext = SunToolkit.targetToAppContext(requester); synchronized (lock) { SunToolkit.postEvent(requesterAppContext, event); while (!event.isDispatched()) { lock.wait(); } } Throwable eventThrowable = event.getThrowable(); if (eventThrowable != null) { throw new InvocationTargetException(eventThrowable); } }
Example #28
Source File: Effect.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
protected static ArrayCache getArrayCache() { ArrayCache cache = (ArrayCache)AppContext.getAppContext().get(ArrayCache.class); if (cache == null){ cache = new ArrayCache(); AppContext.getAppContext().put(ArrayCache.class,cache); } return cache; }
Example #29
Source File: Toolkit.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public synchronized PropertyChangeListener[] getPropertyChangeListeners() { PropertyChangeSupport pcs = (PropertyChangeSupport) AppContext.getAppContext().get(PROP_CHANGE_SUPPORT_KEY); if (null != pcs) { return pcs.getPropertyChangeListeners(); } else { return new PropertyChangeListener[0]; } }
Example #30
Source File: InputMethodEvent.java From jdk8u-jdk with GNU General Public License v2.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); }