答案:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class TextEventDemo extends Applet implements ActionListener
{
TextField tf1,tf2;
public void init()
{
tf1=new TextField(10);
tf2=new TextField(10);
setLayout(new GridLayout(2,1));
add(tf1);
add(tf2);
tf1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource()==tf1)
tf2.setText(tf1.getText());
}
}