Re: [java-gnome-hackers] event code
Brought to you by:
afcowie
|
From: Rubio Jr. <ser...@hi...> - 2002-08-13 16:37:34
|
I like it more.
This will make easy to add future focus events, more swing like.
Anyway it's just my silly opinion.
El mar, 13-08-2002 a las 18:16, Philip A. Chapman escribi=F3:
> Jeff,
>=20
> Thanks for this reference implementation.
>=20
> I do not belive the removeFocusListener will work because a
> WeakReference was added into the Vector, but a listener is being
> removed. I've checked in a few changes that should take care of this
> issue. However, the code changes I've made *should* work as well. I
> like the idea of using Vector rather than WeakHashMap as the Vector
> should be thread-safe without extra work Perhaps we need a WeakVector
> (subclass of Vector) so that the findFocusListener code does not have to
> be implemented for every single listener Vector we use?
>=20
> What do you think of creating a FocusEvent with a type property. That
> way, the listener could implement a single method and tell what kind of
> focus event it received by the type property of the FocusEvent.
>=20
> interface FocusListener
> {
> public void focusEventFired(FocusEvent event);
> }
>=20
> class MyFocusListener
> extends FocusListener
> {
> public void focusEventFired(FocusEvent event)
> {
> if (FocusEvent.getType() =3D=3D FocusEventType.GOT_FOCUS()) {
> // Do Something
>=20
> else if (FocusEvent.getType() =3D=3D FocusEventType.LOST_FOCUS()) {
> // Do Something different
>=20
> } // Else, I don't want to handle it.
> }
> }
>=20
> For this example, it doesn't change much; maybe it even huts some.=20
> However, for a "class" of events which have a lot of different types,
> this may be easier to work with than a lot of different method calls.
>=20
> On Tue, 2002-08-13 at 10:07, Jeffrey Morgan wrote:
> > I have just checked very basic code for event handling
> > into cvs. If you check the gtk.Widget class you can
> > see very simple handling for the focus events. This
> > can serve the basis of our dicussion.
> >=20
> > -Jeff
> --=20
> Philip A. Chapman
|