本帖最后由 杨兴庭 于 2013-7-8 21:05 编辑
import java.awt.*;
import java.awt.event.*;
//import java.awt.event.*;
public class number extends Frame implements ActionListener
{ private Button push;
private TextField x,y,z,m;
public number()
{
super("一个小玩意儿");
setBounds(280,100,300,240);
setLayout(new java.awt.FlowLayout());
add(new Label("请输入个数"));
m=new TextField(10);
add(m);
push=new Button("推我吧");
add(push);
add(new Label("百位"));
x=new TextField(10);
add(x);
add(new Label("十位"));
y=new TextField(10);
add(y);
add(new Label("个位"));
z=new TextField(10);
add(z);
push.addActionListener(this);
setVisible(true);
}
public void ActionListener(ActionEvent e)
{
String s=m.getText();
x.setText(""+s.charAt(0));
y.setText(""+s.charAt(1));
z.setText(""+s.charAt(2));
}
public static void main (String args[])
{
new number();
}
}
显示出来了框架,可是点击push时,事件无从响应,显示以下错误
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
The type number must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent)... |