[java-gnome-hackers] event listeners
Brought to you by:
afcowie
From: Jeffrey M. <Jef...@Br...> - 2002-08-15 14:55:24
|
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 |