⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 toolkit.java

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        synchronized (this) {            SelectiveAWTEventListener selectiveListener =                (SelectiveAWTEventListener) listener2SelectiveListener.get(localL);            if (selectiveListener != null)                listener2SelectiveListener.remove(localL);            eventListener = ToolkitEventMulticaster.remove(eventListener,                 (selectiveListener == null) ? localL : selectiveListener);        }            }    /*     * Extracts a "pure" AWTEventListener from a AWTEventListenerProxy,     * if the listener is proxied.     */    static private AWTEventListener deProxyAWTEventListener(AWTEventListener l)    {        AWTEventListener localL = l;                                                                                        if (localL == null) {            return null;        }        // if user passed in a AWTEventListenerProxy object, extract        // the listener        if (l instanceof AWTEventListenerProxy) {            localL = (AWTEventListener)((AWTEventListenerProxy)l).getListener();        }        return localL;    }    /**     * Returns an array of all the <code>AWTEventListener</code>s     * registered on this toolkit.  Listeners can be returned     * within <code>AWTEventListenerProxy</code> objects, which also contain     * the event mask for the given listener.     * Note that listener objects     * added multiple times appear only once in the returned array.     *     * @return all of the <code>AWTEventListener</code>s or an empty     *         array if no listeners are currently registered     * @throws SecurityException     *        if a security manager exists and its     *        <code>checkPermission</code> method doesn't allow the operation.     * @see      #addAWTEventListener     * @see      #removeAWTEventListener     * @see      SecurityManager#checkPermission     * @see      java.awt.AWTEvent     * @see      java.awt.AWTPermission     * @see      java.awt.event.AWTEventListener     * @see      java.awt.event.AWTEventListenerProxy     * @since 1.4     */    public AWTEventListener[] getAWTEventListeners() {        //6242261        SecurityManager security = System.getSecurityManager();        if (security != null) {            if (listenToAllAWTEventsPermission == null) {                listenToAllAWTEventsPermission =                    new AWTPermission("listenToAllAWTEvents");            }            security.checkPermission(listenToAllAWTEventsPermission);        }        //6242261        synchronized (this) {            EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class);            AWTEventListener[] ret = new AWTEventListener[la.length];            for (int i = 0; i < la.length; i++) {                SelectiveAWTEventListener sael = (SelectiveAWTEventListener)la[i];                AWTEventListener tempL = sael.getListener();                //assert tempL is not an AWTEventListenerProxy - we should                // have weeded them all out                // don't want to wrap a proxy inside a proxy                ret[i] = new AWTEventListenerProxy(sael.getEventMask(), tempL);            }            return ret;        }    }    /**     * Returns an array of all the <code>AWTEventListener</code>s     * registered on this toolkit which listen to all of the event     * types indicates in the <code>eventMask</code> argument.     * Listeners can be returned     * within <code>AWTEventListenerProxy</code> objects, which also contain     * the event mask for the given listener.     * Note that listener objects     * added multiple times appear only once in the returned array.     *     * @param  eventMask the bitmask of event types to listen for     * @return all of the <code>AWTEventListener</code>s registered     *         on this toolkit for the specified     *         event types, or an empty array if no such listeners     *         are currently registered     * @throws SecurityException     *        if a security manager exists and its     *        <code>checkPermission</code> method doesn't allow the operation.     * @see      #addAWTEventListener     * @see      #removeAWTEventListener     * @see      SecurityManager#checkPermission     * @see      java.awt.AWTEvent     * @see      java.awt.AWTPermission     * @see      java.awt.event.AWTEventListener     * @see      java.awt.event.AWTEventListenerProxy     * @since 1.4     */    public AWTEventListener[] getAWTEventListeners(long eventMask) {        //6242261        SecurityManager security = System.getSecurityManager();        if (security != null) {            if (listenToAllAWTEventsPermission == null) {                listenToAllAWTEventsPermission =                    new AWTPermission("listenToAllAWTEvents");            }            security.checkPermission(listenToAllAWTEventsPermission);        }        //6242261        synchronized (this) {            EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class);            java.util.List list = new ArrayList(la.length);            for (int i = 0; i < la.length; i++) {                SelectiveAWTEventListener sael = (SelectiveAWTEventListener)la[i];                if ((sael.getEventMask() & eventMask) == eventMask) {                    //AWTEventListener tempL = sael.getListener();                    list.add(new AWTEventListenerProxy(sael.getEventMask(),                                                       sael.getListener()));                }            }            return (AWTEventListener[])list.toArray(new AWTEventListener[0]);        }    }	    /*     * This method notifies any AWTEventListeners that an event     * is about to be dispatched.     *     * @param theEvent the event which will be dispatched.     */    void notifyAWTEventListeners(AWTEvent theEvent) {        if (eventListener != null) {            synchronized (this) {                if (eventListener != null)                    eventListener.eventDispatched(theEvent);            }        }    }    static private class ToolkitEventMulticaster extends AWTEventMulticaster        implements AWTEventListener {        // Implementation cloned from AWTEventMulticaster.		        ToolkitEventMulticaster(AWTEventListener a, AWTEventListener b) {            super(a, b);        }		        static AWTEventListener add(AWTEventListener a,            AWTEventListener b) {            if (a == null)  return b;            if (b == null)  return a;            return new ToolkitEventMulticaster(a, b);        }		        static AWTEventListener remove(AWTEventListener l,            AWTEventListener oldl) {            return (AWTEventListener) removeInternal(l, oldl);        }		        // #4178589: must overload remove(EventListener) to call our add()        // instead of the static addInternal() so we allocate a        // ToolkitEventMulticaster instead of an AWTEventMulticaster.        // Note: this method is called by AWTEventListener.removeInternal(),        // so its method signature must match AWTEventListener.remove().        protected EventListener remove(EventListener oldl) {            if (oldl == a)  return b;            if (oldl == b)  return a;            AWTEventListener a2 = (AWTEventListener) removeInternal(a, oldl);            AWTEventListener b2 = (AWTEventListener) removeInternal(b, oldl);            if (a2 == a && b2 == b) {                return this;	// it's not here            }            return add(a2, b2);        }		        public void eventDispatched(AWTEvent event) {            ((AWTEventListener) a).eventDispatched(event);            ((AWTEventListener) b).eventDispatched(event);        }    }	    private class SelectiveAWTEventListener implements AWTEventListener {        AWTEventListener listener;        private long eventMask;        static final int LONG_BITS = 64;        // This array contains the number of times to call the eventlistener        // for each event type.        int[] calls = new int[LONG_BITS];        public AWTEventListener getListener() {return listener;}        public long getEventMask() {return eventMask;}        public int[] getCalls() {return calls;}        public void orEventMasks(long mask) {            eventMask |= mask;            // For each event bit set in mask, increment its call count.            for (int i = 0; i < LONG_BITS; i++) {                // If no bits are set, break out of loop.                if (mask == 0) {                    break;                }                if ((mask & 1L) != 0) {  // Always test bit 0.                    calls[i]++;                }                mask >>>= 1;  // Right shift, fill with zeros on left.            }        }		        SelectiveAWTEventListener(AWTEventListener l, long mask) {            listener = l;            eventMask = mask;        }		        public void eventDispatched(AWTEvent event) {            long eventBit = 0; // Used to save the bit of the event type.            if (((eventBit = eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 &&                    event.id >= ComponentEvent.COMPONENT_FIRST &&                    event.id <= ComponentEvent.COMPONENT_LAST)                || ((eventBit = eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0 &&                    event.id >= ContainerEvent.CONTAINER_FIRST &&                    event.id <= ContainerEvent.CONTAINER_LAST)                || ((eventBit = eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0 &&                    event.id >= FocusEvent.FOCUS_FIRST &&                    event.id <= FocusEvent.FOCUS_LAST)                || ((eventBit = eventMask & AWTEvent.KEY_EVENT_MASK) != 0 &&                    event.id >= KeyEvent.KEY_FIRST &&                    event.id <= KeyEvent.KEY_LAST)                || ((eventBit = eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0 &&                    (event.id == MouseEvent.MOUSE_MOVED ||                        event.id == MouseEvent.MOUSE_DRAGGED))                || ((eventBit = eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0 &&                    event.id != MouseEvent.MOUSE_MOVED &&                    event.id != MouseEvent.MOUSE_DRAGGED &&                    event.id >= MouseEvent.MOUSE_FIRST &&                    event.id <= MouseEvent.MOUSE_LAST)                || ((eventBit = eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0 &&                    event.id >= WindowEvent.WINDOW_FIRST &&                    event.id <= WindowEvent.WINDOW_LAST)                || ((eventBit = eventMask & AWTEvent.ACTION_EVENT_MASK) != 0 &&                    event.id >= ActionEvent.ACTION_FIRST &&                    event.id <= ActionEvent.ACTION_LAST)                || ((eventBit = eventMask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0 &&                    event.id >= AdjustmentEvent.ADJUSTMENT_FIRST &&                    event.id <= AdjustmentEvent.ADJUSTMENT_LAST)                || ((eventBit = eventMask & AWTEvent.ITEM_EVENT_MASK) != 0 &&                    event.id >= ItemEvent.ITEM_FIRST &&                    event.id <= ItemEvent.ITEM_LAST)                || ((eventBit = eventMask & AWTEvent.TEXT_EVENT_MASK) != 0 &&                    event.id >= TextEvent.TEXT_FIRST &&                    event.id <= TextEvent.TEXT_LAST)                            /*|| ((eventBit = eventMask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0 &&                 event.id >= InputMethodEvent.INPUT_METHOD_FIRST &&                 event.id <= InputMethodEvent.INPUT_METHOD_LAST)                 || ((eventBit = eventMask & AWTEvent.PAINT_EVENT_MASK) != 0 &&                 event.id >= PaintEvent.PAINT_FIRST &&                 event.id <= PaintEvent.PAINT_LAST)                 || ((eventBit = eventMask & AWTEvent.INVOCATION_EVENT_MASK) != 0 &&                 event.id >= InvocationEvent.INVOCATION_FIRST &&                 event.id <= InvocationEvent.INVOCATION_LAST)                 || ((eventBit = eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0 &&                 event.id == HierarchyEvent.HIERARCHY_CHANGED)                 || ((eventBit = eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0 &&                 (event.id == HierarchyEvent.ANCESTOR_MOVED ||                 event.id == HierarchyEvent.ANCESTOR_RESIZED))*/) {                // Get the index of the call count for this event type.                int ci = (int) (Math.log(eventBit) / Math.log(2));                // Call the listener as many times as it was added for this                // event type.                for (int i = 0; i < calls[ci]; i++) {                    listener.eventDispatched(event);                }            }        }    }    /**     * Returns a map of visual attributes for the abstract level description     * of the given input method highlight, or null if no mapping is found.     * The style field of the input method highlight is ignored. The map     * returned is unmodifiable.     * @param highlight input method highlight     * @return style attribute map, or <code>null</code>     * @exception HeadlessException if     *     <code>GraphicsEnvironment.isHeadless</code> returns true     * @see       java.awt.GraphicsEnvironment#isHeadless     * @since 1.3     *//*    public abstract Map mapInputMethodHighlight(        InputMethodHighlight highlight) throws HeadlessException;*/    /**     * Returns whether Toolkit supports this state for     * <code>Frame</code>s.  This method tells whether the <em>UI     * concept</em> of, say, maximization or iconification is     * supported.  It will always return false for "compound" states     * like <code>Frame.ICONIFIED|Frame.MAXIMIZED_VERT</code>.     * In other words, the rule of thumb is that only queries with a     * single frame state constant as an argument are meaningful.     *     * @param state one of named frame state constants.     * @return <code>true</code> is this frame state is supported by     *     this Toolkit implementation, <code>false</code> otherwise.     * @exception HeadlessException     *     if <code>GraphicsEnvironment.isHeadless()</code>     *     returns <code>true</code>.     * @since   1.4     */    public boolean isFrameStateSupported(int state)        throws HeadlessException    {        return (state == Frame.NORMAL); // others are not supported    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -