Example usage for java.awt Canvas getListeners

List of usage examples for java.awt Canvas getListeners

Introduction

In this page you can find the example usage for java.awt Canvas getListeners.

Prototype

@SuppressWarnings("unchecked")
public <T extends EventListener> T[] getListeners(Class<T> listenerType) 

Source Link

Document

Returns an array of all the objects currently registered as FooListeners upon this Component .

Usage

From source file:Main.java

public static void removeListenerMouse(Class clazz, Canvas canvas) {
    for (Object event : canvas.getListeners(clazz)) {
        if (clazz == MouseListener.class) {
            canvas.removeMouseListener((MouseListener) event);
        } else {/* w  w w  .  j  a v  a2s.  c o m*/
            if (clazz == MouseMotionListener.class) {
                canvas.removeMouseMotionListener((MouseMotionListener) event);
            }
        }
    }
}