Hi, I am confused over this. Can enableEvent and Adapters be used together ? I think.... the answer is No. Can anyone help ?
posted 15 years ago
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?