It's not a secret anymore!*
The moose likes Beginning Java and the fly likes What do you think of the answer to this question about listener? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What do you think of the answer to this question about listener? " Watch "What do you think of the answer to this question about listener? " New topic
Author

What do you think of the answer to this question about listener?

Woo Hwang
Greenhorn

Joined: Aug 07, 2001
Posts: 13
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?
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What do you think of the answer to this question about listener?