java类java.awt.event.MouseMotionListener的实例源码

ScriptEngine.java 文件源码 项目:Parabot-317-API-Minified-PkHonor 阅读 44 收藏 0 点赞 0 评论 0
public void init() {
    if (script == null) {
        throw new RuntimeException("Script is null");
    }
    if (script instanceof MouseListener) {
        addMouseListener((MouseListener) script);
    }
    if (script instanceof MouseMotionListener) {
        addMouseMotionListener((MouseMotionListener) script);
    }
    if (script instanceof MessageListener) {
        addMessageListener((MessageListener) script);
    }
    if (script instanceof Paintable) {
        Context.getInstance().addPaintable((Paintable) script);
    }
    if (script instanceof GameActionListener) {
        addActionListener((GameActionListener) script);
    }
}
ScriptEngine.java 文件源码 项目:Parabot-317-API-Minified-Dreamscape 阅读 41 收藏 0 点赞 0 评论 0
public void init() {
    if (script == null) {
        throw new RuntimeException("Script is null");
    }
    if (script instanceof MouseListener) {
        addMouseListener((MouseListener) script);
    }
    if (script instanceof MouseMotionListener) {
        addMouseMotionListener((MouseMotionListener) script);
    }
    if (script instanceof MessageListener) {
        addMessageListener((MessageListener) script);
    }
    if (script instanceof Paintable) {
        Context.getInstance().addPaintable((Paintable) script);
    }
    if (script instanceof GameActionListener) {
        addActionListener((GameActionListener) script);
    }
}
RTextAreaBase.java 文件源码 项目:powertext 阅读 36 收藏 0 点赞 0 评论 0
/**
 * Adds listeners that listen for changes to the current line, so we can
 * update our "current line highlight."  This is needed only because of an
 * apparent difference between the JRE 1.4.2 and 1.5.0 (needed on 1.4.2,
 * not needed on 1.5.0).
 */
private void addCurrentLineHighlightListeners() {
    boolean add = true;
    MouseMotionListener[] mouseMotionListeners = getMouseMotionListeners();
    for (int i=0; i<mouseMotionListeners.length; i++) {
        if (mouseMotionListeners[i]==mouseListener) {
            add = false;
            break;
        }
    }
    if (add) {
        //System.err.println("Adding mouse motion listener!");
        addMouseMotionListener(mouseListener);
    }
    MouseListener[] mouseListeners = getMouseListeners();
    for (int i=0; i<mouseListeners.length; i++) {
        if (mouseListeners[i]==mouseListener) {
            add = false;
            break;
        }
    }
    if (add) {
        //System.err.println("Adding mouse listener!");
        addMouseListener(mouseListener);
    }
}
Canvas.java 文件源码 项目:freecol 阅读 33 收藏 0 点赞 0 评论 0
/**
 * Checks if this {@code Canvas} contains any in game components.
 *
 * @return {@code true} if there is any in game components.
 */
public boolean containsInGameComponents() {
    KeyListener[] keyListeners = getKeyListeners();
    if (keyListeners.length > 0) {
        return true;
    }

    MouseListener[] mouseListeners = getMouseListeners();
    if (mouseListeners.length > 0) {
        return true;
    }

    MouseMotionListener[] mouseMotionListeners = getMouseMotionListeners();
    if (mouseMotionListeners.length > 0) {
        return true;
    }

    return false;
}
Canvas.java 文件源码 项目:freecol 阅读 32 收藏 0 点赞 0 评论 0
/**
 * Removes components that is only used when in game.
 */
public void removeInGameComponents() {
    // remove listeners, they will be added when launching the new game...
    KeyListener[] keyListeners = getKeyListeners();
    for (KeyListener keyListener : keyListeners) {
        removeKeyListener(keyListener);
    }

    MouseListener[] mouseListeners = getMouseListeners();
    for (MouseListener mouseListener : mouseListeners) {
        removeMouseListener(mouseListener);
    }

    MouseMotionListener[] mouseMotionListeners = getMouseMotionListeners();
    for (MouseMotionListener mouseMotionListener : mouseMotionListeners) {
        removeMouseMotionListener(mouseMotionListener);
    }

    for (Component c : getComponents()) {
        removeFromCanvas(c);
    }
}
InGameMenuBar.java 文件源码 项目:freecol 阅读 36 收藏 0 点赞 0 评论 0
/**
 * Creates a new {@code FreeColMenuBar}. This menu bar will include
 * all of the submenus and items.
 *
 * @param freeColClient The main controller.
 * @param listener An optional mouse motion listener.
 */
public InGameMenuBar(FreeColClient freeColClient, MouseMotionListener listener) {
    // FIXME: FreeColClient should not have to be passed in to
    // this class.  This is only a menu bar, it doesn't need a
    // reference to the main controller.  The only reason it has
    // one now is because DebugMenu needs it.  And DebugMenu needs
    // it because it is using inner classes for ActionListeners
    // and those inner classes use the reference.  If those inner
    // classes were in seperate classes, when they were created,
    // they could use the FreeColClient reference of the
    // ActionManger.  So DebugMenu needs to be refactored to remove
    // inner classes so that this MenuBar can lose its unnecessary
    // reference to the main controller.  See FreeColMenuTest.
    //
    // Okay, I lied.. the update() and paintComponent() methods in
    // this MenuBar use freeColClient, too. But so what.  Move
    // those to another class too. :)
    super(freeColClient);

    // Add a mouse listener so that autoscrolling can happen in
    // this menubar
    this.addMouseMotionListener(listener);

    reset();
}
Panel.java 文件源码 项目:VTerminal 阅读 36 收藏 0 点赞 0 评论 0
/**
 * Adds an event listener to the Panel.
 *
 * @param eventListener
 *        The event listener.
 *
 * @throws IllegalArgumentException
 *        If the event listener isn't supported by this function.
 */
public void addListener(final EventListener eventListener) {
    if (eventListener instanceof KeyListener) {
        this.addKeyListener((KeyListener) eventListener);
        return;
    }

    if (eventListener instanceof MouseListener) {
        this.addMouseListener((MouseListener) eventListener);
        return;
    }

    if (eventListener instanceof MouseMotionListener) {
        this.addMouseMotionListener((MouseMotionListener) eventListener);
        return;
    }

    throw new IllegalArgumentException("The " + eventListener.getClass().getSimpleName() + " is not supported.");
}
Panel.java 文件源码 项目:VTerminal 阅读 34 收藏 0 点赞 0 评论 0
/**
 * Removes an event listener from the Panel.
 *
 * @param eventListener
 *        The event listener.
 *
 * @throws IllegalArgumentException
 *        If the event listener isn't supported by this function.
 */
public void removeListener(final EventListener eventListener) {
    if (eventListener instanceof KeyListener) {
        this.removeKeyListener((KeyListener) eventListener);
        return;
    }

    if (eventListener instanceof MouseListener) {
        this.removeMouseListener((MouseListener) eventListener);
        return;
    }

    if (eventListener instanceof MouseMotionListener) {
        this.removeMouseMotionListener((MouseMotionListener) eventListener);
        return;
    }

    throw new IllegalArgumentException("The " + eventListener.getClass().getSimpleName() + " is not supported.");
}
ScriptEngine.java 文件源码 项目:Parabot-317-API-Minified-OS-Scape 阅读 39 收藏 0 点赞 0 评论 0
public void init() {
        if (script == null) {
            throw new RuntimeException("Script is null");
        }
        if (script instanceof MouseListener) {
            addMouseListener((MouseListener) script);
        }
        if (script instanceof MouseMotionListener) {
            addMouseMotionListener((MouseMotionListener) script);
        }
//        if (script instanceof MessageListener) {
//            addMessageListener((MessageListener) script);
//        }
        if (script instanceof Paintable) {
            Context.getInstance().addPaintable((Paintable) script);
        }
//        if (script instanceof GameActionListener) {
//            addActionListener((GameActionListener) script);
//        }
    }
SelectionManager.java 文件源码 项目:Cognizant-Intelligent-Test-Scripter 阅读 29 收藏 0 点赞 0 评论 0
public void removeListener() {
    for (MouseListener ml : com.getMouseListeners()) {
        com.removeMouseListener(ml);
    }
    for (MouseMotionListener mml : com.getMouseMotionListeners()) {
        com.removeMouseMotionListener(mml);
    }
    for (KeyListener kl : com.getKeyListeners()) {
        com.removeKeyListener(kl);
    }
    reset();
    com.repaint();
}
Canvas.java 文件源码 项目:FreeCol 阅读 39 收藏 0 点赞 0 评论 0
/**
 * Checks if this {@code Canvas} contains any in game components.
 *
 * @return {@code true} if there is any in game components.
 */
public boolean containsInGameComponents() {
    KeyListener[] keyListeners = getKeyListeners();
    if (keyListeners.length > 0) {
        return true;
    }

    MouseListener[] mouseListeners = getMouseListeners();
    if (mouseListeners.length > 0) {
        return true;
    }

    MouseMotionListener[] mouseMotionListeners = getMouseMotionListeners();
    if (mouseMotionListeners.length > 0) {
        return true;
    }

    return false;
}
Canvas.java 文件源码 项目:FreeCol 阅读 34 收藏 0 点赞 0 评论 0
/**
 * Removes components that is only used when in game.
 */
public void removeInGameComponents() {
    // remove listeners, they will be added when launching the new game...
    KeyListener[] keyListeners = getKeyListeners();
    for (KeyListener keyListener : keyListeners) {
        removeKeyListener(keyListener);
    }

    MouseListener[] mouseListeners = getMouseListeners();
    for (MouseListener mouseListener : mouseListeners) {
        removeMouseListener(mouseListener);
    }

    MouseMotionListener[] mouseMotionListeners = getMouseMotionListeners();
    for (MouseMotionListener mouseMotionListener : mouseMotionListeners) {
        removeMouseMotionListener(mouseMotionListener);
    }

    for (Component c : getComponents()) {
        removeFromCanvas(c);
    }
}
InGameMenuBar.java 文件源码 项目:FreeCol 阅读 32 收藏 0 点赞 0 评论 0
/**
 * Creates a new {@code FreeColMenuBar}. This menu bar will include
 * all of the submenus and items.
 *
 * @param freeColClient The main controller.
 * @param listener An optional mouse motion listener.
 */
public InGameMenuBar(FreeColClient freeColClient, MouseMotionListener listener) {
    // FIXME: FreeColClient should not have to be passed in to
    // this class.  This is only a menu bar, it doesn't need a
    // reference to the main controller.  The only reason it has
    // one now is because DebugMenu needs it.  And DebugMenu needs
    // it because it is using inner classes for ActionListeners
    // and those inner classes use the reference.  If those inner
    // classes were in seperate classes, when they were created,
    // they could use the FreeColClient reference of the
    // ActionManger.  So DebugMenu needs to be refactored to remove
    // inner classes so that this MenuBar can lose its unnecessary
    // reference to the main controller.  See FreeColMenuTest.
    //
    // Okay, I lied.. the update() and paintComponent() methods in
    // this MenuBar use freeColClient, too. But so what.  Move
    // those to another class too. :)
    super(freeColClient);

    // Add a mouse listener so that autoscrolling can happen in
    // this menubar
    this.addMouseMotionListener(listener);

    reset();
}
ApparatusPanel.java 文件源码 项目:PhET 阅读 34 收藏 0 点赞 0 评论 0
/**
 * Sets up mouse and key listeners
 */
protected void setMouseAndKeyListeners( MouseInputListener mouseHandler, KeyListener keyAdapter ) {
    // Clear the old handlers
    MouseListener[] mouseListeners = this.getMouseListeners();
    for ( int i = 0; i < mouseListeners.length; i++ ) {
        MouseListener mouseListener = mouseListeners[i];
        this.removeMouseListener( mouseListener );
    }
    MouseMotionListener[] mouseMostionListeners = this.getMouseMotionListeners();
    for ( int i = 0; i < mouseMostionListeners.length; i++ ) {
        MouseMotionListener mouseMostionListener = mouseMostionListeners[i];
        this.removeMouseMotionListener( mouseMostionListener );
    }
    KeyListener[] keyListeners = this.getKeyListeners();
    for ( int i = 0; i < keyListeners.length; i++ ) {
        KeyListener keyListener = keyListeners[i];
        this.removeKeyListener( keyListener );
    }

    // Add the new handlers
    this.addMouseListener( mouseHandler );
    this.addMouseMotionListener( getGraphic().getMouseHandler() );
    this.addKeyListener( keyAdapter );
}
CCSystem.java 文件源码 项目:FCMFrame 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Set whether the coordinate system is movable with the mouse, i.e.
 * the scope of the system changes as the the mouse is clicked, held
 * and dragged over the system.
 * 
 * @param movable
 *        If true, move is possible.
 */
public void setMovable(boolean movable) {
    if (this.movable && movable) return;
    if (!this.movable && !movable) return;

    if (movable) {
        addMouseListener(mouseListener);
        addMouseMotionListener((MouseMotionListener) mouseListener);
    }
    else {
        removeMouseListener(mouseListener);
        removeMouseMotionListener((MouseMotionListener) mouseListener);
    }

    movable = !movable;
}
RTextAreaBase.java 文件源码 项目:ftc 阅读 34 收藏 0 点赞 0 评论 0
/**
 * Adds listeners that listen for changes to the current line, so we can
 * update our "current line highlight."  This is needed only because of an
 * apparent difference between the JRE 1.4.2 and 1.5.0 (needed on 1.4.2,
 * not needed on 1.5.0).
 */
private void addCurrentLineHighlightListeners() {
    boolean add = true;
    MouseMotionListener[] mouseMotionListeners = getMouseMotionListeners();
    for (int i=0; i<mouseMotionListeners.length; i++) {
        if (mouseMotionListeners[i]==mouseListener) {
            add = false;
            break;
        }
    }
    if (add==true) {
        //System.err.println("Adding mouse motion listener!");
        addMouseMotionListener(mouseListener);
    }
    MouseListener[] mouseListeners = getMouseListeners();
    for (int i=0; i<mouseListeners.length; i++) {
        if (mouseListeners[i]==mouseListener) {
            add = false;
            break;
        }
    }
    if (add==true) {
        //System.err.println("Adding mouse listener!");
        addMouseListener(mouseListener);
    }
}
RTextAreaBase.java 文件源码 项目:Tank 阅读 28 收藏 0 点赞 0 评论 0
/**
 * Adds listeners that listen for changes to the current line, so we can update our "current line highlight." This
 * is needed only because of an apparent difference between the JRE 1.4.2 and 1.5.0 (needed on 1.4.2, not needed on
 * 1.5.0).
 */
protected void addCurrentLineHighlightListeners() {
    boolean add = true;
    MouseMotionListener[] mouseMotionListeners = getMouseMotionListeners();
    for (int i = 0; i < mouseMotionListeners.length; i++) {
        if (mouseMotionListeners[i] == mouseListener) {
            add = false;
            break;
        }
    }
    if (add == true) {
        // System.err.println("Adding mouse motion listener!");
        addMouseMotionListener(mouseListener);
    }
    MouseListener[] mouseListeners = getMouseListeners();
    for (int i = 0; i < mouseListeners.length; i++) {
        if (mouseListeners[i] == mouseListener) {
            add = false;
            break;
        }
    }
    if (add == true) {
        // System.err.println("Adding mouse listener!");
        addMouseListener(mouseListener);
    }
}
RTextAreaBase.java 文件源码 项目:Tank 阅读 40 收藏 0 点赞 0 评论 0
/**
 * Adds listeners that listen for changes to the current line, so we can update our "current line highlight." This
 * is needed only because of an apparent difference between the JRE 1.4.2 and 1.5.0 (needed on 1.4.2, not needed on
 * 1.5.0).
 */
protected void addCurrentLineHighlightListeners() {
    boolean add = true;
    MouseMotionListener[] mouseMotionListeners = getMouseMotionListeners();
    for (int i = 0; i < mouseMotionListeners.length; i++) {
        if (mouseMotionListeners[i] == mouseListener) {
            add = false;
            break;
        }
    }
    if (add == true) {
        // System.err.println("Adding mouse motion listener!");
        addMouseMotionListener(mouseListener);
    }
    MouseListener[] mouseListeners = getMouseListeners();
    for (int i = 0; i < mouseListeners.length; i++) {
        if (mouseListeners[i] == mouseListener) {
            add = false;
            break;
        }
    }
    if (add == true) {
        // System.err.println("Adding mouse listener!");
        addMouseListener(mouseListener);
    }
}
RTextAreaBase.java 文件源码 项目:ESPlorer 阅读 28 收藏 0 点赞 0 评论 0
/**
 * Adds listeners that listen for changes to the current line, so we can
 * update our "current line highlight."  This is needed only because of an
 * apparent difference between the JRE 1.4.2 and 1.5.0 (needed on 1.4.2,
 * not needed on 1.5.0).
 */
private void addCurrentLineHighlightListeners() {
    boolean add = true;
    MouseMotionListener[] mouseMotionListeners = getMouseMotionListeners();
    for (int i=0; i<mouseMotionListeners.length; i++) {
        if (mouseMotionListeners[i]==mouseListener) {
            add = false;
            break;
        }
    }
    if (add==true) {
        //System.err.println("Adding mouse motion listener!");
        addMouseMotionListener(mouseListener);
    }
    MouseListener[] mouseListeners = getMouseListeners();
    for (int i=0; i<mouseListeners.length; i++) {
        if (mouseListeners[i]==mouseListener) {
            add = false;
            break;
        }
    }
    if (add==true) {
        //System.err.println("Adding mouse listener!");
        addMouseListener(mouseListener);
    }
}
HUDFrameHeader2D.java 文件源码 项目:openwonderland 阅读 26 收藏 0 点赞 0 评论 0
public void notifyMouseMotionListeners(final MouseEvent e) {
    SwingWorker worker = new SwingWorker<String, Object>() {

        @Override
        public String doInBackground() {
            if (mouseMotionListeners != null) {
                e.setSource(this);
                ListIterator<MouseMotionListener> iter = mouseMotionListeners.listIterator();
                while (iter.hasNext()) {
                    MouseMotionListener listener = iter.next();

                    switch (e.getID()) {
                        case MouseEvent.MOUSE_MOVED:
                            listener.mouseMoved(e);
                            break;
                        case MouseEvent.MOUSE_DRAGGED:
                            listener.mouseDragged(e);
                            break;
                        default:
                            break;
                    }
                }
                iter = null;
            }
            return null;
        }
    };
    worker.execute();
    try {
        worker.get();
    } catch (Exception ie) {
    }
}
HUDView2D.java 文件源码 项目:openwonderland 阅读 29 收藏 0 点赞 0 评论 0
public void notifyMouseMotionListeners(MouseEvent e) {
    if (mouseMotionListeners != null) {
        e.setSource(this);
        ListIterator<MouseMotionListener> iter = mouseMotionListeners.listIterator();
        while (iter.hasNext()) {
            MouseMotionListener listener = iter.next();

            switch (e.getID()) {
                case MouseEvent.MOUSE_MOVED:
                    listener.mouseMoved(e);
                    break;
                case MouseEvent.MOUSE_DRAGGED:
                    listener.mouseDragged(e);
                    break;
                default:
                    break;
            }
        }
        iter = null;
    }
}
Window2D.java 文件源码 项目:openwonderland 阅读 47 收藏 0 点赞 0 评论 0
/**
 * Deliver the given mouse motion event to the window.
 *
 * @param event The mouse motion event to deliver.
 */
private void deliverMouseMotionEvent(MouseEvent event) {
    if (mouseMotionListeners == null) {
        return;
    }

    for (MouseMotionListener listener : mouseMotionListeners) {
        switch (event.getID()) {
            case MouseEvent.MOUSE_MOVED:
                listener.mouseMoved(event);
                break;
            case MouseEvent.MOUSE_DRAGGED:
                listener.mouseDragged(event);
                break;
        }
    }
}
Window2D.java 文件源码 项目:openwonderland 阅读 31 收藏 0 点赞 0 评论 0
/**
 * Remove a listener for mouse motion events.
 *
 * @param listener The mouse motion listener to remove.
 */
public void removeMouseMotionListener(MouseMotionListener listener) {
    if (app == null) {
        return;
    }
    synchronized (app.getAppCleanupLock()) {
        synchronized (this) {
            if (mouseMotionListeners == null) {
                return;
            }
            mouseMotionListeners.remove(listener);
            if (mouseMotionListeners.size() == 0) {
                mouseMotionListeners = null;
            }
        }
    }
}
HeaderPanel.java 文件源码 项目:openwonderland 阅读 28 收藏 0 点赞 0 评论 0
@Override
public void addMouseMotionListener(final MouseMotionListener listener) {
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            HeaderPanel.super.addMouseMotionListener(listener);
            if (appLabel != null) {
                appLabel.addMouseMotionListener(listener);
            }
            if (controllerLabel != null) {
                controllerLabel.addMouseMotionListener(listener);
            }
            if (closeButton != null) {
                closeButton.addMouseMotionListener(listener);
            }
            if (hudButton != null) {
                hudButton.addMouseMotionListener(listener);
            }
        }
    });
}
HeaderPanel.java 文件源码 项目:openwonderland 阅读 31 收藏 0 点赞 0 评论 0
@Override
public void removeMouseMotionListener(final MouseMotionListener listener) {
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            HeaderPanel.super.removeMouseMotionListener(listener);
            if (appLabel != null) {
                appLabel.removeMouseMotionListener(listener);
            }
            if (controllerLabel != null) {
                controllerLabel.removeMouseMotionListener(listener);
            }
            if (closeButton != null) {
                closeButton.removeMouseMotionListener(listener);
            }
            if (hudButton != null) {
                hudButton.removeMouseMotionListener(listener);
            }
        }
    });
}
MungePen.java 文件源码 项目:power-matchmaker 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Removes all listeners associated with the given Component. This is useful when removing to to make sure
 * it does not stick around.
 */
public static void removeAllListeners(Component com) {
    for (FocusListener fl : com.getFocusListeners()) {
        com.removeFocusListener(fl);
    }

    for (MouseListener ml : com.getMouseListeners()) {
        com.removeMouseListener(ml);
    }

    for (MouseMotionListener mml : com.getMouseMotionListeners()) {
        com.removeMouseMotionListener(mml);
    }

    for (KeyListener kl : com.getKeyListeners()) {
        com.removeKeyListener(kl);
    }

    for (ComponentListener cl : com.getComponentListeners()) {
        com.removeComponentListener(cl);
    }
}
SelectionManager.java 文件源码 项目:kkMulticopterFlashTool 阅读 42 收藏 0 点赞 0 评论 0
public void mouseClicked(MouseEvent event)
  {
if ((activeObject != null) && activeObject.contains(event.getX(), event.getY()))
{
    eventRelay.relay("mouseClicked", event);
}
else
{
    if (event.getClickCount() == 2)
    {
        if (selectedObject != null)
        {
            activeObject = selectedObject;
            Component component = activeObject.getComponent();
            if (component != null)
            {
                eventRelay.reset();
                eventRelay.addTarget(component, MouseListener.class, MouseEvent.class, mouseNames);
                eventRelay.addTarget(component, MouseMotionListener.class, MouseEvent.class, mouseMotionNames);
                selectableContainer.select(selectedObject, false);
            }
        }
    }
}
  }
MouseInterceptPanel.java 文件源码 项目:kkMulticopterFlashTool 阅读 31 收藏 0 点赞 0 评论 0
public void setMouseMotionIntercept(MouseMotionListener listener)
{
    if (mouseMotionIntercept instanceof MouseMotionListener)
        removeMouseMotionListener(mouseMotionIntercept);
    mouseMotionIntercept = listener;
    if (mouseMotionIntercept instanceof MouseMotionListener)
    {
        removeMouseMotionListener(this);
        addMouseMotionListener(mouseMotionIntercept);
        mouseMotionPassThrough = false;
    }
    else
    {
        addMouseMotionListener(this);
        mouseMotionPassThrough = true;
    }
}
MouseDispatcher.java 文件源码 项目:cn1 阅读 32 收藏 0 点赞 0 评论 0
private void dispatchMotionEvent(PointerInfo info, NativeEvent event) {
    propagateEvent(info, AWTEvent.MOUSE_MOTION_EVENT_MASK,
                   MouseMotionListener.class, false);
    final Point pos = info.position;
    if ((lastUnderMotion != info.src) ||
        !lastLocalPos.equals(pos)) {

        lastUnderMotion = info.src;
        lastLocalPos = pos;

        if (info.src.isIndirectlyEnabled()) {
            toolkit.getSystemEventQueueImpl().postEvent(
                        new MouseEvent(info.src, event.getEventId(),
                        event.getTime(),
                        event.getInputModifiers(),
                        pos.x, pos.y, 0, false));
        }
    }
}
Component.java 文件源码 项目:cn1 阅读 44 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
    if (ComponentListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getComponentListeners();
    } else if (FocusListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getFocusListeners();
    } else if (HierarchyBoundsListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyBoundsListeners();
    } else if (HierarchyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getHierarchyListeners();
    } else if (InputMethodListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getInputMethodListeners();
    } else if (KeyListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getKeyListeners();
    } else if (MouseWheelListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseWheelListeners();
    } else if (MouseMotionListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseMotionListeners();
    } else if (MouseListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getMouseListeners();
    } else if (PropertyChangeListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getPropertyChangeListeners();
    }
    return (T[]) Array.newInstance(listenerType, 0);
}


问题


面经


文章

微信
公众号

扫码关注公众号