wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes enableEvent and Adapters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "enableEvent and Adapters" Watch "enableEvent and Adapters" New topic
Author

enableEvent and Adapters

Aru
Ranch Hand

Joined: Jul 20, 2000
Posts: 112
Hi,
I am confused over this.
Can enableEvent and Adapters be used together ?
I think.... the answer is No.
Can anyone help ?

Aruna
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
The objective of enableEvent(...) is to make sure that the component gets the specifed event (ie. it's processEvent() method gets called) even if no listener is registered for that event.
Generally, a component does not do anything for a particular event if no listener is registered. So there is no point to pass the event to the component.
There may be needs where a component wants to do something even if no listener is registered.
For eg. You may want to create MyButton, which keeps count of how many times it was clicked. (Of course, this can be done by adding a listener) SO, it may enable action events and override it's processEvent method to keep the count. So even if no actionListener is added to it, it will still process the action event.
Now, Adapters are for a totally different reason. You can add a some subclass of say MouseAdapter and also explicitly call enableEvent() but calling enableEvent() would be redundant because adding a listener automatically enables the resp. event.
I don't know whether this is what you were looking for. Could you be more specific as to how you want to use them together?

HTH,
Paul.
Get Certified, Guaranteed! http://pages.about.com/jqplus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: enableEvent and Adapters