Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-05-2008, 06:22 PM
Member
 
Join Date: Jan 2008
Posts: 39
mcal is on a distinguished road
Class explanation
Hey guys, i have a problem with this class. I can't understand exactly what is really doing. Can someone pls help me understand it? Thanks a lot.

This is the code:


Code:
import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Calendar; import javax.swing.event.EventListenerList; public class ActionSupport { protected EventListenerList listenerList = new EventListenerList(); private Object bean; public ActionSupport(Object registeredBean) { this.bean = registeredBean; } public void fireActionPerformed(String actionCommand) { Object[] listeners = listenerList.getListenerList(); ActionEvent e = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ActionListener.class) { e = new ActionEvent(bean, ActionEvent.ACTION_PERFORMED, actionCommand, Calendar.getInstance().getTimeInMillis(), 0); ((ActionListener) listeners[i + 1]).actionPerformed(e); } } } public void addActionListener(ActionListener l) { listenerList.add(ActionListener.class, l); } public void removeActionListener(ActionListener l) { listenerList.remove(ActionListener.class, l); } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-05-2008, 08:50 PM
roots's Avatar
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 263
roots is on a distinguished road
It is multiplexing the callback to more than one classes . Different listeners can be registered to this class and when the action is triggered this class calls all the listeners.
__________________
dont worry newbie, we got you covered.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the Priority for execution of Interface class and a Abstract class Santoshbk Advanced Java 0 04-02-2008 09:04 AM
Inner class accessing outer class Java Tip Java Tips 0 02-17-2008 10:59 AM
need a little explanation cew27 New To Java 7 12-14-2007 01:39 AM
Explanation bout threading and concurrency? cruxblack New To Java 1 08-10-2007 12:33 PM
I need didactic explanation Eric New To Java 2 07-02-2007 07:37 AM


All times are GMT +3. The time now is 12:12 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org