[kaffe] Bug report: MouseListeners, getComponentAt

Dalibor Topic robilad@yahoo.com
Tue Feb 18 03:16:01 2003


--0-2081442182-1045567027=:67377
Content-Type: text/plain; charset=us-ascii
Content-Id: 
Content-Disposition: inline

hi David,

thanks for the bug report. I've looked into it and
created an updated version of the test (attached).

It seems to show (among other things ;), that kaffe's
AWT event handling sometimes can't decide properly
which event propagation model to use: the one from jdk
1.0 (propagate up the component tree untill someone
handles it), or the one from jdk 1.1 (events are
handled at component tree leaves). 

So if you run the updated test on  JDK 1.1 and click
on the button, you should see a 'clicked' message,
while clicking on other  leaves of the component tree
will result in no message, because jdk 1.1 uses the
1.1 event model to (not) propagate the event up to the
frame.

topic@clerks:~/bugs/novalis>
/usr/lib/j2sdk1.4.1_01/bin/java DemoPanelBug
enabled: true
DemoPanelBug[frame0,0,0,50x88,layout=java.awt.GridLayout,title=,resizable,normal]
java.awt.Canvas[canvas0,5,25,25x29]
java.awt.Label[label0,30,25,25x29,align=left,text=a]
java.awt.Button[button0,5,54,25x29,label=b]
java.awt.Panel[panel0,30,54,25x29,layout=java.awt.FlowLayout]
event:
java.awt.event.MouseEvent[MOUSE_CLICKED,(9,10),button=1,modifiers=Button1,clickCount=1]
on button0
Clicked
DemoPanelBug[frame0,0,0,50x88,layout=java.awt.GridLayout,title=,resizable,normal]
at java.awt.Point[x=9,y=10]

If you run the updated test on kaffe, you'll notice
that it propagates the event unless it's been handled
by the component, which is the jdk 1.0 model.

topic@clerks:~/bugs/novalis>
~/kaffe-sound-shared/bin/java DemoPanelBug
enabled: true
DemoPanelBug[frame0,0,0,96x124,layout=java.awt.GridLayout,resizable,title=]
java.awt.Canvas[canvas0,0,22,48x47]
java.awt.Label[null,48,22,48x47,Label: a]
java.awt.Button[null,0,69,48x47,Label: b]
java.awt.Panel[panel0,48,69,48x47,layout=java.awt.FlowLayout]
event:
java.awt.MouseEvt[MOUSE_CLICKED,(68,43),mods=16,clickCount=1]
on frame0
Clicked java.awt.Label[null,48,22,48x47,Label: a] at
java.awt.Point[x=68,y=43]
event:
java.awt.MouseEvt[MOUSE_CLICKED,(22,44),mods=16,clickCount=1]
on frame0
Clicked java.awt.Canvas[canvas0,0,22,48x47] at
java.awt.Point[x=22,y=44]
event:
java.awt.MouseEvt[MOUSE_CLICKED,(76,95),mods=16,clickCount=1]
on frame0
Clicked
java.awt.Panel[panel0,48,69,48x47,layout=java.awt.FlowLayout]
at java.awt.Point[x=76,y=95]
event:
java.awt.MouseEvt[MOUSE_CLICKED,(25,28),mods=16,clickCount=1]
on java.awt.Button
Clicked java.awt.Canvas[canvas0,0,22,48x47] at
java.awt.Point[x=25,y=28]

I'll first have to fix the toString methods of the
classes involved, though. You could try to take a look
at the event propagation in kaffe's
java.awt.Component.java, Button.java etc. and try to
find out why it's using the inappropriate event
handling model. Of course, pointers to documentation
describing when one should pick which event
propagation model are welcome, too, as I find the docs
on that from Sun somewhat lacking ;)

cheers,
dalibor topic

__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com
--0-2081442182-1045567027=:67377
Content-Type: application/octet-stream; name="DemoPanelBug.java"
Content-Transfer-Encoding: base64
Content-Description: DemoPanelBug.java
Content-Disposition: attachment; filename="DemoPanelBug.java"

LyoKVG8gdHJpZ2dlciB0aGUgYnVnOiBDbGljayBvbiBlYWNoIG9mIHRoZSBm
b3VyIHF1YXJ0ZXJzIG9mIHRoZSBncmlkLCBpbgpjbG9ja3dpc2Ugb3JkZXIu
CgpLYWZmZSBmcm9tIERlYmlhbi4gLXZlcnNpb24gZ2l2ZXMgCidFbmdpbmU6
IEp1c3QtaW4tdGltZSAgIFZlcnNpb246IDEuMC43ICAgSmF2YSBWZXJzaW9u
OiAxLjEnCgpPdXRwdXQgaXM6CkNsaWNrZWQgamF2YS5hd3QuQ2FudmFzW2Nh
bnZhczAsMCwwLDQ4eDYyXSBhdCBqYXZhLmF3dC5Qb2ludFt4PTMzLHk9NDBd
CkNsaWNrZWQgamF2YS5hd3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