java简单的编程

来源:百度知道 编辑:UC知道 时间:2024/05/11 03:43:36
初学java 希望好心人 解释一下
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class zh extends Applet implements ActionListener
{ Button button1;
TextField text;
public void init(){
text=new TextField(11);
add(text);
button1=new Button("enter");
text.addActionListener(this);
add(button1);
button1.addActionListenter(this);
}
public void actionPerformed(ActionEvent e)
{if (e.getSource()==button1)
{text.setText(button1.getLabel());}
}
}
简单、的
但是报错 x希望找出报错 原因

button1.addActionListenter(this);
应为 ^多个T
button1.addActionListener(this);
楼主给分

button1.addActionListenter(this); 应为:

button1.addActionListener(this);

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class zh extends Applet implements ActionListener
{ Button button1;
TextField text;
public void init(){
text=new TextField(11);
add(text);
button1=new Button("enter");
button1.addActionListener(this);
add(button1);
}
public void actionPerformed(ActionEvent e)
{if (e.getSource()==button1)
{text.setText(button1.getLabel());}
}
}
1.text.addActionListener(this);多余
2.button1.addActionListen(t)er(this);手误
其中第二个是主要原因