Re: [java-gnome-hackers] event code
Brought to you by:
afcowie
From: Jeffrey M. <ku...@zo...> - 2002-08-13 18:11:15
|
I like the idea. I want to create a new package to contain the interfaces and the event classes. Perhaps org.gnu.gtk.event. I will create this package, create the event class, update the Widget class and add a few additional events. I will check this updated code in sometime this evening. I need to check off for now. I should be back online late tonight. -Jeff On Tue, 2002-08-13 at 12:16, Philip A. Chapman wrote: > 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. > > interface FocusListener > { > public void focusEventFired(FocusEvent event); > } > > class MyFocusListener > extends FocusListener > { > public void focusEventFired(FocusEvent event) > { > if (FocusEvent.getType() == FocusEventType.GOT_FOCUS()) { > // Do Something > > else if (FocusEvent.getType() == FocusEventType.LOST_FOCUS()) { > // Do Something different > > } // Else, I don't want to handle it. > } > } > > For this example, it doesn't change much; maybe it even huts some. > 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. > |