• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Diff. between Event listener & Event Mask ?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got questions regarding Explicit Event Enabling (a alternative to component's event)
Under what conditions this XXX_EVENT_MASK is used,Or we can work only with regular event delgation model without even knowing about it.
Please clear about the above diffrence to make me understand about this topic.
Thanks in advance for reply
D_malik
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its just another way of doing the same thing. There are listeners provided for every event and you could use them.
Option 1:
Button myButton = new Button();
myButton.addActionListener(new ActionListener() {} );
Option 2:
class myButton extends Button {

enableEvents(ACTION_EVENT_MASK);
public void processActionEvent(ActionEvent e) {};
}

Option 3: // which is almost same as option 2
class myButton extends Button {

enableEvents(ACTION_EVENT_MASK);
public void processEvent(AWTEvent e) {
if e.getID() == ACTION_EVENT_MASK };
}

Hope it helps,
Harry
 
D_malik
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Harry
I am not still clear in what condition this processEvent methods are used or it just a another approach to Event model.
Dharam
 
Harry Singh
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dharam,
You are right. Its another way of doing things. It depends on the design. Lets say you are writing a calculator and each button is just supposed to write to the display when it is clicked. You can either create 10 buttons ( 1,2,3 ... ) and add Listeners to them individaully. Instead why not subclass Button, add the ProcessEvent and ENABLE_EVENT code and do it once. I hope it makes sense.
Thanks,
Harry
 
reply
    Bookmark Topic Watch Topic
  • New Topic