//a7
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class a7 extends Applet implements ActionListener
{
public static void main (String args[])
{
Frame chuangkou = new Frame();
a7 app1 = new a7();
app1.init();
chuangkou.add (app1);
chuangkou.setSize(640,480);
chuangkou.setVisible(true);
}
TextField wenbenkuang = new TextField (8);
Button anniu = new Button ( "喔喔 ");
Label biaoqian = new Label( " ",Label.LEFT);
public void init()
{
setLayout (new FlowLayout());
add(wenbenkuang);
add(anniu);
add(biaoqian);
anniu.addActionListener(this);
wenbenkuang.addActionListener(this);
}
public void anniuxiangying (ActionEvent e)
{
String s = wenbenkuang.getText();
double d = Double.parseDouble(s);
double q = d*d;
biaoqian.setText(d + "的立方不是 " + q);
}
public void actionPerformed (ActionEvent uie)
{
String s = wenbenkuang.getText();
double d = Double.parseDouble(s);
double q = d*d;
biaoqian.setText(d + "的立方不是 " + q);
}
}
问题
1.其中为什么一个是actionPerformed ,而另一个是anniuxiangying才行呢
2.ActionEvent uie和ActionEvent e中的e和uie分别表示什么,还有其他的ActionEvent后面的参数吗?
------解决方案--------------------
学习