Re: [java-gnome-hackers] event listeners
Brought to you by:
afcowie
From: Rubio Jr. <ser...@hi...> - 2002-08-15 15:23:02
|
Umm, I like the second aproach. The event should be an object, it is something that can be represented by an abstract data type. It is not a behavior of an object. Rubio Jr. On Thu, 2002-08-15 at 16:55, Jeffrey Morgan wrote: > I would like to get everybody's opinion on something. > Is it better to define a method on a listener interface > for each type of event or is it better to define one > method and have the event class specify the type. For > example: > > Option 1: A method for each type of event > > public interface KeyListener { > public void keyPressed(KeyEvent event); > public void keyReleased(KeyEvent event); > }; > > > Option 2: A single method with the KeyEvent > specifying the actual event. > > public interface KeyListener { > public void keyEvent(KeyEvent event); > }; > > if (event.getId() == KeyEvent.PRESSED) > ... > > Let me know what your thoughts. > > -Jeff |