Making your class an event source in Java
- by Crystal
I'm making a custom button in Java that has two states, mousePressed, and mouseReleased.  At the same time, if I wanted to reuse this button, so that other event listeners can register with it, are these the appropriate steps I should do:
override addActionListener(ActionListener action)
override removeActionListener(ActionListener action)
have a private variable like List <ActionListener> list = new List <ActionListener>() to keep track of when events get added
and some sort of function with for loop to run all the actions:
public void runListeners()
{
    for (ActionListener al : list) {
        al.actionPerfomed;
    }
}
I'm not really sure if this is the way you can do it or if there are other things I am missing.  Like does my custom class have to be implements ActionListener?  Thanks.