import java.awt.*;
import java.awt.event.*;
public class hello3 implements ActionListener
{
public static void main(String args[])
{
Frame win=new Frame( "windows ");
TextField t1=new TextField(10);
win.add(t1);
t1.addActionListener(this);
win.pack();
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==t1)
t1.setText( "java ");
}
}
}
------解决方案--------------------
actionPerformed函数的定义放到main函数处边去。