import java.awt.*;
import java.awt.event.*;
class Mywindow extends Frame implements ActionListener
{
TextField a,b;
Mywindow()
{
setLayout(new FlowLayout());
a = new TextField(8);
b = new TextField(8);
add(a);
add(b);
a.addActionListener(this);
b.addActionListener(this);
setBounds(100,100,400,400);
setVisible(true);
validate();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == a)
{
String word = a.getText();
if(word.equals( "boy "))
{
b.setText( "男孩 ");
}
else
{
b.setText( "没有该单词 ");
}
}
}
}
public class TextField
{
public static void main(String[] args)
{
Mywindow win = new Mywindow();
}
}
错误错在哪里呢????
------解决方案--------------------
命名有冲突了,将启动类的名称改一下就行了……