🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #8420

Re: Multiple Event Listeners For One event

#8420
From: Ali Demir
Date: Wed, 16 Aug 2000 00:00
59 lines
2315 bytes
Thank you very much Dave. That's a good idea. How about if the event is
fired in someone else's code? What do people do in that case most of the
time? AWT events etc? Is there a common practice?
Thanks
ali

"David Jefferson" <david.jefferson@kbcfp.com> wrote in message
news:399a8d44_1@dnews...
> One way would be to define your listener's method to have a boolean return
> value (true for event handled, false otherwise), then in your fireEvent
> method when you are enumerating through the listeners as soon as one of
them
> returns true then you can return ie something like this:
>
> public interface MyListener
> {
>     public boolean handleEvent(MyEvent e);
> }
>
> // -------------------- In class which listeners are listening
> to ---------------------
>
> private void fireEvent(MyEvent e)
> {
>     for (Enumeration enum = m_listeners.elements();
enum.hasMoreElements();)
>     {
>         MyListener myListener = (MyListener) enum.nextElement();
>         if (myListener.handleEvent(e)) return;
>     }
> }
>
> The other, related model which is quite cool is vetoable change listeners
> which may be appropriate.
>
> Dave
>
> "Ali Demir" <demir.4@osu.edu> wrote in message news:399a025d$1_2@dnews...
> > Hello,
> >
> > I have Multiple Event Listeners For One event. If one of the listeners
> > handles the event, I would like other listeners to skip this event.
> >
> > Is there a recommended way of implementing a design pattern so that this
> > kind of problem is nicely handled?
> >
> > For example it would be nice if the event class had a property which I
> could
> > set to 'handled'...
> >
> > All advice is welcome.
> > Thank you in advance.
> >
> > Ali Demir
> > demir.4@osu.edu
> >
> >
>
>
Technical Details
Message-ID: <399b75b0$1_1@dnews>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <399a025d$1_2@dnews> <399a8d44_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,3998603c7ea30180
X-Google-Attributes: gid111d45,public
From: "Ali Demir" <ademir@informix.com>
Subject: Re: Multiple Event Listeners For One event
Date: 2000/08/16
Message-ID: <399b75b0$1_1@dnews>
X-Deja-AN: 659216636
References: <399a025d$1_2@dnews> <399a8d44_1@dnews>
X-Trace: 16 Aug 2000 22:18:40 -0800, 24.19.144.88
X-MSMail-Priority: Normal
X-Priority: 3
Newsgroups: borland.public.jbuilder.java.swing
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700