• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

enableEvents

 
Leandro Oliveira
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what really does this code:
enableEvents(AWTEvent.ACTION_EVENT_MASK);
???
I saw it in a code. It also had a method called processActionEvent, but the class did not implement actionListener. Could someone clarify?

thanks in advance.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the low-level way that AWT processes events... All events aren't enabled for all components, that's why only some components can have ActionListeners added to them, and that's why you have to call enableEvents(), to enable to component to handel that class of events. All components also have a generic processEvent() method. This method calls processXXXEvent() methods based on what type of event it gets. So processActionEvent() gets sent all ActionEvents. Normally, this method would handle ActionEvents by handing them off to ActionListeners attached to them. Instead, the behavior is written right there in the method. Basically, this "hardcodes" behavior into the component that can't be overridden by a listener.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic