Article View: borland.public.jbuilder.java.language
Article #7830Re: Questions about the java event model (jdk1.2)
From: Joi Ellis [TeamB]
Date: Thu, 17 May 2001 15:50
Date: Thu, 17 May 2001 15:50
43 lines
2794 bytes
2794 bytes
Francesco Milesi <francesco.milesi@inetconsulting.it> wrote: > I know thet the actual java event model is the delegation model (that > substituted the containment model) , based on a source target interaction. > Here are the questions: > 1. I read on a jguru course that AWT events are not garanteed to be > dispatched in a definite order: is this true even in the jdk1.2 , so that if > you register two listeners with the same source and the second need the > result of the response of the first, this is not a good idea, because it is > not guaranteed that the second listener will receive the event after the > first one? As far as I know, yes. > 2. Is this true even for swing classes ? I was conviced that events are > processed synchronously and that they are dispatched in the order listeners > are registered, because the source take them out in order from the list (a > Vector I think) and call the adhoc method of the listener (say > actionPerformed, for example). If you look at the source for some classes, you can see that the listeners are stored in a vector and dispatched in the vector's enumerator/iterator order, which happens to be the order in which the items were added. However, you can't guarantee that all classes are written this way, or will continue to be written this way. If the order isn't specified by the API or the interface, its risky to rely upon implementation details like this. If the API docs don't promise a particular order, you shouldn't reply upon the order. > 3. Why is there this difference (if there is any) between AWT and swing? Possibly because AWT is based upon native peers more than Swing is, and so is tied more closely to platform specific behaviors. I never make any assumptions about event order. -- Joi Ellis (TeamB) No direct email, please. For best results, post on news server newsgroups.borland.com! Newsgroup Info: http://www.borland.com/newsgroups/guide.html
Technical Details
Message-ID:
<3b03f35b_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.sj.google.com!newsfeed.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews!not-for-mailReferences:
<3b03ed9a_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,4be102475d3f54d0
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-05-17 09:20:07 PST
Message-ID: <3b03f35b_1@dnews>
From: "Joi Ellis [TeamB]" <joi@aravox.com>
Subject: Re: Questions about the java event model (jdk1.2)
Newsgroups: borland.public.jbuilder.java.language
References: <3b03ed9a_2@dnews>
User-Agent: tin/1.4.2-20000205 ("Possession") (UNIX) (Linux/2.2.16-3 (i686))
NNTP-Posting-Host: 209.46.41.66
Date: 17 May 2001 08:50:51 -0700
X-Trace: dnews 990114651 209.46.41.66 (17 May 2001 08:50:51 -0700)
Lines: 43
Path: arc1-ca.pugleaf.net!archiver1.sj.google.com!newsfeed.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews!not-for-mail