import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Applet extends JApplet {
      private ActionListener bli = new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    String name = ((JButton)e.getSource()).getText();
    txt.setText(name);
  }
};
private JButton
    b1 = new JButton("Button 1"),
    b2 = new JButton("Button 2");
  private JTextField txt = new JTextField(10);
public void init() {
    b1.addActionListener(bli);
    b2.addActionListener(bli);
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());
    cp.add(b1);
    cp.add(b2);
    cp.add(txt);
}
}

/*<applet code=AnApplet.class width=200 height=200>
</applet>
*/