Java编译错误:ClickMe不是抽象的, 并且未覆盖ActionListener中的抽象方法actionPerformed(ActionEvent)
哪位大侠知道怎么解决,求教啊!编译时提示:importjava.awt.*;importjava.awt.event.ActionEvent;importjava.awt...
哪位大侠知道怎么解决,求教啊!
编译时提示:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ClickMe extends Frame implements ActionListener{
private Button quit = new Button("Quit");
private Button click = new Button("Click here");
private TextField text = new TextField(10);
private boolean secondClick = false;
public ClickMe(){
super("Click Example");
setLayout(new FlowLayout());
add(quit);add(click);
click.addActionListener(this);
quit.addActionListener(this);
add(text);
pack();setVisible(true);
}
public void actionPerfomed(ActionEvent e){
if(e.getSource() == quit)
System.exit(0);
elseif(e.getSource() == click){
if (secondClick)
text.setText("not again!");
else
text.setText("Uh,it tickles");
secondClick = !secondClick;
}
}
public static void main(String[] args){
ClickMe myFrame = new ClickMe();
}
} 展开
编译时提示:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ClickMe extends Frame implements ActionListener{
private Button quit = new Button("Quit");
private Button click = new Button("Click here");
private TextField text = new TextField(10);
private boolean secondClick = false;
public ClickMe(){
super("Click Example");
setLayout(new FlowLayout());
add(quit);add(click);
click.addActionListener(this);
quit.addActionListener(this);
add(text);
pack();setVisible(true);
}
public void actionPerfomed(ActionEvent e){
if(e.getSource() == quit)
System.exit(0);
elseif(e.getSource() == click){
if (secondClick)
text.setText("not again!");
else
text.setText("Uh,it tickles");
secondClick = !secondClick;
}
}
public static void main(String[] args){
ClickMe myFrame = new ClickMe();
}
} 展开
2个回答
2014-06-17
展开全部
ActionListener 有一个方法没得到实现actionperforme(。。。),因为clickme
类不是抽象类所以必须实现,加上方法就好了
类不是抽象类所以必须实现,加上方法就好了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询