/////// ButtonApplet.java /////// import java.applet.Applet; import java.awt.event.*; import java.awt.*; public class ButtonApplet extends Applet { private TextField t; private Button b; public void init() { b = new Button("Cuenta Eventos en Clase no Anónima"); t = new TextField(5); b.addActionListener(new MyActionListener(t)); add(b); add(t); } } class MyActionListener implements ActionListener { TextField _t; int count; MyActionListener(TextField t) { _t = t; count=0; } public void actionPerformed(ActionEvent e) { _t.setText(" "+ (++count)); } }