Example usage for java.awt Component removeMouseMotionListener

List of usage examples for java.awt Component removeMouseMotionListener

Introduction

In this page you can find the example usage for java.awt Component removeMouseMotionListener.

Prototype

public synchronized void removeMouseMotionListener(MouseMotionListener l) 

Source Link

Document

Removes the specified mouse motion listener so that it no longer receives mouse motion events from this component.

Usage

From source file:Main.java

/**
 * Inserts the mouse motion listener at the particular index in the listeners' chain.
 *
 * @param component/*from  ww w  . j a v  a 2 s  . c o m*/
 * @param l
 * @param index
 */
public static void insertMouseMotionListener(Component component, MouseMotionListener l, int index) {
    MouseMotionListener[] listeners = component.getMouseMotionListeners();

    for (MouseMotionListener listener : listeners) {
        component.removeMouseMotionListener(listener);
    }

    for (int i = 0; i < listeners.length; i++) {
        MouseMotionListener listener = listeners[i];

        if (index == i) {
            component.addMouseMotionListener(l);
        }

        component.addMouseMotionListener(listener);
    }

    // inex is too large, add to the end.
    if (index > listeners.length - 1) {
        component.addMouseMotionListener(l);
    }
}

From source file:edu.ku.brc.ui.UIHelper.java

/**
 * Removes the Mouse Listeners.//from   w  ww .  ja v a2s.c  o m
 * @param c component
 */
public static void removeMouseListeners(final Component c) {
    if (c != null) {
        for (MouseListener l : c.getMouseListeners()) {
            c.removeMouseListener(l);
        }
        for (MouseMotionListener l : c.getMouseMotionListeners()) {
            c.removeMouseMotionListener(l);
        }
    }
}