EventListenerList.remove parameters

Discussion in 'Java' started by -, Aug 1, 2005.

  1. -

    - Guest

    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]);
    }
    }
    }
     
    -, Aug 1, 2005
    #1
    1. Advertising

  2. - 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 == 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/
     
    Thomas Hawtin, Aug 1, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon-Pierre  Jarry
    Replies:
    2
    Views:
    2,412
    Henrik
    Aug 10, 2005
  2. -
    Replies:
    0
    Views:
    354
  3. -
    Replies:
    1
    Views:
    431
    jan V
    Jul 23, 2005
  4. tshad
    Replies:
    6
    Views:
    21,533
    tshad
    Aug 8, 2006
  5. Michel Albert
    Replies:
    6
    Views:
    319
    Aaron Brady
    Apr 13, 2009
Loading...

Share This Page