This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: AWT Events


Shane Nay wrote:

> I really need to know how events are propagated in java AWT normally, like
> are they bubble down, or bubble up.  When I get events from Pgui heavyweights
> they come attached to the particular widget, so that would logically lead to
> sending the event right to the widget.  However, I don't think this is the
> "normal AWTy" way of doing things..., I think maybe you give it to the top,
> and it bubbles down to the component.  What do you all think?, and would
> short circuiting event propagation in the case of heavyweights break
> applications?

For heavyweight components, you are right in that events are sent "directly" to
the AWT counterpart object to the peer that generated them. In the peer code you
need to do something like the following:

1. When your Toolkit class is initialized, create a java.awt.EventQueue object
and keep a reference to it somewhere. Creating the EventQueue will start the
event dispatch thread, effectively initializing the AWT.

2. When you receive an event from the native toollkit, construct the appropriate
AWTEvent object setting "source" to the AWT object which is generating the
event. Then, you just need to call queue.postEvent() and the rest should
hopefully be taken care of: the dispatch thread will call the correct event
listeners via the "source" component.

(Looking at your pgui code it looks like you've got most of this down already)

In the case of lightweight components, the event is sent to the nearest
heavyweight component, and then "bubbled down" to the appropriate lightweight
component object via a LightweightDispatcher class. I'm not sure how well our
LightweightDispatcher works currently. Certainly it looks a bit inefficient.

> I am still making sure the project can be
> integrated into libgcj at some point in terms of contributers, license, etc.)

Cool, thats good to hear.

regards

  [ bryce ]



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]