Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > EventListenerList.remove parameters

Reply
Thread Tools

EventListenerList.remove parameters

 
 
-
Guest
Posts: n/a
 
      08-01-2005
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[i] == c) {
eventListenerList.remove(c, eventListeners[i + 1]);
}
}
}
 
Reply With Quote
 
 
 
 
Thomas Hawtin
Guest
Posts: n/a
 
      08-01-2005
- wrote:
> 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[i] == 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
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
skipping template parameters inside template parameters kito C++ 2 09-26-2010 12:04 AM
Class Member Data and Member Function Parameters - Should Parameters Be Data Members? Jason C++ 2 05-13-2006 07:11 AM
commands to configure WLAN adapter parameters =?Utf-8?B?SmFnYW4=?= Wireless Networking 0 10-05-2005 11:37 AM
does a "parameters"-parameter overwrite the "parameters"-object? Florian Loitsch Javascript 11 03-15-2005 03:33 PM
Servlet parameters different from the command line parameters? Jonck van der Kogel Java 2 05-26-2004 11:34 PM



Advertisments