import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;

public class UmApplet extends Applet 
{
	public void init() {
		setLayout(new BorderLayout());
		add("North",new Label("Fontes e ouvintes...",Label.CENTER));
		
		TextArea texto = new TextArea(10,20);
		add("Center",texto);
		
		Panel botoes = new Panel();
		add("South",botoes);
		
		Button xxx = new Button("Ouvem-me pouco");
		botoes.add(xxx);
		
		Button yyy = new Button("Ouvem-me muito");
		botoes.add(yyy);
		
		Ouvinte o = new Ouvinte(texto);
		OuvinteCurioso oc = new OuvinteCurioso(texto);
		
		xxx.addActionListener(o);
		yyy.addActionListener(o); yyy.addActionListener(oc);
	}
	
}

class Ouvinte implements ActionListener {
	TextArea sitioOndeEscrever;
	
	Ouvinte(TextArea t) {
		sitioOndeEscrever=t;
	}
	
	public void actionPerformed(ActionEvent e){
		sitioOndeEscrever.append("Deve estar ai alguem\n");
	}
}

class OuvinteCurioso implements ActionListener {
	TextArea sitioOndeEscrever;
	OuvinteCurioso(TextArea t) {
		sitioOndeEscrever=t;
	}
	public void actionPerformed(ActionEvent e){
		sitioOndeEscrever.append("Que curioso:\n"+e+"\n"+"Source:"+e.getSource()+"\n");
		if (e.getSource() instanceof Button) {
			sitioOndeEscrever.append("Botao:"+((Button)e.getSource()).getLabel()+"\n");
		}
	}
}