初学者的送分题,先来者先得
初学JAVA,我用的JDK4.1.2,IDE是JCreator pro2.5
按书上的例子敲得。
import java.awt.*;
import java.awt.event.*;
public class ApplicationGraphicsInOut
{
public static void main(String args[])
{
new FrameInOut();
}
}
class FrameInOut extends Frame implements ActionListener
{
Label prompt;
TextField input,output;
FrameInOut()
{
super("图形界面的java Application程序");
prompt=new Label("请输入你的名字");
input=new TextField(6);
output=new TextField(20);
setLayout(new FlowLayout());
add(prompt);
add(input);
add(output);
input.addActionListener(this);
setSize(300,200);
show();
}
public void acitonPerformed(ActionEvent e)
{
output.setText(input.getText()+",欢迎你!");
}
}
编译时出现错误:
--------------------Configuration: Batch Process - j2sdk1.4.2 <Default>--------------------
D:\java\ApplicationGraphicsInOut\ApplicationGraphicsInOut.java:24: FrameInOut is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
class FrameInOut extends Frame implements ActionListener
^
1 error
请问怎么解决,谢谢
问题点数:10、回复次数:4Top
1 楼whwjn(哈哈)回复于 2003-08-03 00:21:14 得分 0
怎么回事,别人都看不到?Top
2 楼chongchong2001(虫虫)回复于 2003-08-03 03:03:08 得分 10
public void acitonPerformed(ActionEvent e)
{
output.setText(input.getText()+",欢迎你!");
}
actionPerformed()方法没有定义
因为你的actionPerformed写成了acitonPerformed
拼写错误!
^_^Top
3 楼niko7(掠水无痕)回复于 2003-08-03 11:40:39 得分 0
呵呵,正是!这种错还真搞死人的,建议你用自动拼写检查吧。
jbuilder 可以的,不知道别的编辑器怎么样。
Top
4 楼whwjn(哈哈)回复于 2003-08-03 12:04:03 得分 0
哈哈,低级错误,谢谢,给分。Top




