import javax.swing. * ; import java.awt. * ; import java.awt.event. * ; import java.applet. * ; public class Jtxt extends JApplet implements ActionListener ... { Container cp=getContentPane(); JLabel lb1=new JLabel("输入后回车"); JLabel lb2=new JLabel("显示输出结果:"); JTextField tf1= new JTextField(10); JTextArea tf2=new JTextArea(10,5); public void init() ...{ cp.setLayout(new FlowLayout()); cp.add(lb1); cp.add(tf1); cp.add(lb2); cp.add(tf2); tf1.addActionListener(this); } public void actionPerformed(ActionEvent e) ...{ String str; str=tf1.getText(); tf2.append(str+" "); }} 注:actionPerformed方法的第一个字母a为小写。。JAVA大小写太敏感了。。郁闷。。