I found this question from one of my favorite SCJP websites. It has an answer, but I doubt it, so I put this question again. Which statements about listeners are true? a. At most one listener can be added to any single component. b. If multiple listeners are added to a single component, the order of invocation of the listener is not specified. c. The return value from a listener is used to control the invocation of other listeners d. In the java package, listener methods generally take an argument which is an instance of the some subclass of java.awt.AWTEvent class They said the answer were b,d. Yes, I agree to b, but I'm not sure of d. Can somebody give me an answer for this?
Hi Woo, If d was not true then your listener would be clueless as to what brought it there. For example: WindowListeners expect WindowEvent to figure out what window event called the listener method ActionListeners expect ActionEvent to figure out what action event called the listener method. ComponentListeners expect ComponentEvent to figure out what component called the listener method. KeyListeners expect KeyEvent to figure out what key was pressed. MouseListeners expect MouseEvent to figure out what mouse button was pressed. All xxxxxEvent are subclasses of java.awt.AWTEvent class. Regards, Manfred.