EventListenerList.remove parameters

?

-

I'm having problems with the eventListenerList.remove(c,
eventListeners[i + 1]).

What should i do to cast it?

public void removeAllListeners(Class c) {
Object[] eventListeners = eventListenerList.getListenerList();
for (int i = eventListeners.length - 2; i >= 0; i -= 2) {
if (eventListeners == c) {
eventListenerList.remove(c, eventListeners[i + 1]);
}
}
}
 
T

Thomas Hawtin

- said:
I'm having problems with the eventListenerList.remove(c,
eventListeners[i + 1]).

What should i do to cast it?

public void removeAllListeners(Class c) {
Object[] eventListeners = eventListenerList.getListenerList();
for (int i = eventListeners.length - 2; i >= 0; i -= 2) {
if (eventListeners == c) {
eventListenerList.remove(c, eventListeners[i + 1]);
}
}
}


The second argument to the remove method should be cast to
java.util.EventListener.

(And with generics you'll get an unchecked cast warning...)

Tom Hawtin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top