interface ActionListener{
public void actionPerformed(ActionEvent e);
}
class MyActionListener implements ActionListener{
public void actionPerformed(ActionEvent e){
System.out.println("press");
}
}
class ActionEvent{
long when;
public ActionEvent(long when){
this.when = when;
}
pulbic long getWhen(){
return when;
}
}
class Button{
private List<ActionListener> actionListener = new ArrayList<ActionListener>();
public void buttonPressed(){
ActionEvent e = new ActionEvent(System.currentTimeMillis(), this);
for(int i=0; i<actionListeners.size(); i++){
ActionListener l = actionListeners.get(i);
l.actionPerformed(e);
}
}
public void addActionListener(ActionListener l){
actionListeners.add(l);
}
}
public class TestAWT{
public static void main(String[] args){
Button b = new Button();
b.addActionListener(new MyActionListener());
b.buttonPressed();
}
}