src/java.desktop/share/classes/java/awt/Toolkit.java

Print this page




1705      * @see java.awt.Dialog.ModalExclusionType
1706      * @see java.awt.Window#getModalExclusionType
1707      * @see java.awt.Window#setModalExclusionType
1708      *
1709      * @since 1.6
1710      */
1711     public abstract boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType);
1712 
1713     // 8014718: logging has been removed from SunToolkit
1714 
1715     private static final int LONG_BITS = 64;
1716     private int[] calls = new int[LONG_BITS];
1717     private static volatile long enabledOnToolkitMask;
1718     private AWTEventListener eventListener = null;
1719     private WeakHashMap<AWTEventListener, SelectiveAWTEventListener> listener2SelectiveListener = new WeakHashMap<>();
1720 
1721     /*
1722      * Extracts a "pure" AWTEventListener from a AWTEventListenerProxy,
1723      * if the listener is proxied.
1724      */
1725     static private AWTEventListener deProxyAWTEventListener(AWTEventListener l)
1726     {
1727         AWTEventListener localL = l;
1728 
1729         if (localL == null) {
1730             return null;
1731         }
1732         // if user passed in a AWTEventListenerProxy object, extract
1733         // the listener
1734         if (l instanceof AWTEventListenerProxy) {
1735             localL = ((AWTEventListenerProxy)l).getListener();
1736         }
1737         return localL;
1738     }
1739 
1740     /**
1741      * Adds an AWTEventListener to receive all AWTEvents dispatched
1742      * system-wide that conform to the given <code>eventMask</code>.
1743      * <p>
1744      * First, if there is a security manager, its <code>checkPermission</code>
1745      * method is called with an


1990      *
1991      * @param theEvent the event which will be dispatched.
1992      */
1993     void notifyAWTEventListeners(AWTEvent theEvent) {
1994         // This is a workaround for headless toolkits.  It would be
1995         // better to override this method but it is declared package private.
1996         // "this instanceof" syntax defeats polymorphism.
1997         // --mm, 03/03/00
1998         if (this instanceof HeadlessToolkit) {
1999             ((HeadlessToolkit)this).getUnderlyingToolkit()
2000                 .notifyAWTEventListeners(theEvent);
2001             return;
2002         }
2003 
2004         AWTEventListener eventListener = this.eventListener;
2005         if (eventListener != null) {
2006             eventListener.eventDispatched(theEvent);
2007         }
2008     }
2009 
2010     static private class ToolkitEventMulticaster extends AWTEventMulticaster
2011         implements AWTEventListener {
2012         // Implementation cloned from AWTEventMulticaster.
2013 
2014         ToolkitEventMulticaster(AWTEventListener a, AWTEventListener b) {
2015             super(a, b);
2016         }
2017 
2018         @SuppressWarnings("overloads")
2019         static AWTEventListener add(AWTEventListener a,
2020                                     AWTEventListener b) {
2021             if (a == null)  return b;
2022             if (b == null)  return a;
2023             return new ToolkitEventMulticaster(a, b);
2024         }
2025 
2026         @SuppressWarnings("overloads")
2027         static AWTEventListener remove(AWTEventListener l,
2028                                        AWTEventListener oldl) {
2029             return (AWTEventListener) removeInternal(l, oldl);
2030         }




1705      * @see java.awt.Dialog.ModalExclusionType
1706      * @see java.awt.Window#getModalExclusionType
1707      * @see java.awt.Window#setModalExclusionType
1708      *
1709      * @since 1.6
1710      */
1711     public abstract boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType);
1712 
1713     // 8014718: logging has been removed from SunToolkit
1714 
1715     private static final int LONG_BITS = 64;
1716     private int[] calls = new int[LONG_BITS];
1717     private static volatile long enabledOnToolkitMask;
1718     private AWTEventListener eventListener = null;
1719     private WeakHashMap<AWTEventListener, SelectiveAWTEventListener> listener2SelectiveListener = new WeakHashMap<>();
1720 
1721     /*
1722      * Extracts a "pure" AWTEventListener from a AWTEventListenerProxy,
1723      * if the listener is proxied.
1724      */
1725     private static AWTEventListener deProxyAWTEventListener(AWTEventListener l)
1726     {
1727         AWTEventListener localL = l;
1728 
1729         if (localL == null) {
1730             return null;
1731         }
1732         // if user passed in a AWTEventListenerProxy object, extract
1733         // the listener
1734         if (l instanceof AWTEventListenerProxy) {
1735             localL = ((AWTEventListenerProxy)l).getListener();
1736         }
1737         return localL;
1738     }
1739 
1740     /**
1741      * Adds an AWTEventListener to receive all AWTEvents dispatched
1742      * system-wide that conform to the given <code>eventMask</code>.
1743      * <p>
1744      * First, if there is a security manager, its <code>checkPermission</code>
1745      * method is called with an


1990      *
1991      * @param theEvent the event which will be dispatched.
1992      */
1993     void notifyAWTEventListeners(AWTEvent theEvent) {
1994         // This is a workaround for headless toolkits.  It would be
1995         // better to override this method but it is declared package private.
1996         // "this instanceof" syntax defeats polymorphism.
1997         // --mm, 03/03/00
1998         if (this instanceof HeadlessToolkit) {
1999             ((HeadlessToolkit)this).getUnderlyingToolkit()
2000                 .notifyAWTEventListeners(theEvent);
2001             return;
2002         }
2003 
2004         AWTEventListener eventListener = this.eventListener;
2005         if (eventListener != null) {
2006             eventListener.eventDispatched(theEvent);
2007         }
2008     }
2009 
2010     private static class ToolkitEventMulticaster extends AWTEventMulticaster
2011         implements AWTEventListener {
2012         // Implementation cloned from AWTEventMulticaster.
2013 
2014         ToolkitEventMulticaster(AWTEventListener a, AWTEventListener b) {
2015             super(a, b);
2016         }
2017 
2018         @SuppressWarnings("overloads")
2019         static AWTEventListener add(AWTEventListener a,
2020                                     AWTEventListener b) {
2021             if (a == null)  return b;
2022             if (b == null)  return a;
2023             return new ToolkitEventMulticaster(a, b);
2024         }
2025 
2026         @SuppressWarnings("overloads")
2027         static AWTEventListener remove(AWTEventListener l,
2028                                        AWTEventListener oldl) {
2029             return (AWTEventListener) removeInternal(l, oldl);
2030         }