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:
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);
}
}