简体   繁体   中英

How can handleEvent() be replaced by processEvent()?

The handleEvent() component method is marked as deprecated and replaced with processEvent() .

But how can this replacing occur? handleEvent() was having a return value to indicate whether the event was processed or not, while processEvent() has no such return value.

So how does processEvent() signal that it was unable to process the event?

In Java 1.1 the AWT event model was completely changed and replaced the Event class with the AWTEvent class, used up to (at least) Java 1.8. As with every major rewriting, it's hard to pinpoint an exact reason.

It's probable that since the AWTEvent has a isConsumed method there was no need for handleEvent() to return the value. The "is consumed \\ processed" information is related to the event itself and not to a component, so it makes more sense for this informations to be returned from the event ( isConsumed ) and not the component ( processEvent() \\ handleEvent() ). Event did not contain such information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM