帮看下这段代码

来源:百度知道 编辑:UC知道 时间:2024/09/21 06:59:19
import java.awt.*;
import java.awt.event.* ;
class window extends Frame implements ActionListener
{
TextField text1,text2,text3;
window (String s)
{
super (s);
setLayout(new FlowLayout());
text1=new TextField(10);
text2=new TextField(10);
text3=new TextField(10);
add (text1);
add (text2);
add (text3);
text1.addActionListener(this);
setBounds(100,100,150,150);
setVisible(true);
validate();
}
public void actionperformed (ActionEvent e)
{
int n=10,m=0,l=0;
try
{
n=Integer.parseInt(text1.getText());
m=n*n;
l=n*n*n;
text1.setText(n+"的平方是:"+m);
text2.setText(n+"的立方是:"+l);
}
catch (Exception ee)
{
text1.setText("请输入字符");
text2.setText(null);
text3.setText(null);
}
}
}
class yellow4
{public static void main (String args[])
{
window win=new window("窗口&q

编译通过了,自己理解哦
import java.awt.*;
import java.awt.event.* ;
class window extends Frame implements ActionListener
{
TextField text1,text2,text3;
window (String s)
{
super (s);
setLayout(new FlowLayout());
text1=new TextField(10);
text2=new TextField(10);
text3=new TextField(10);
add (text1);
add (text2);
add (text3);
text1.addActionListener(this);
setBounds(100,100,150,150);
setVisible(true);
validate();
}
public void actionperformed (ActionEvent e)
{
int n=10,m=0,l=0;
try
{
n=Integer.parseInt(text1.getText());
m=n*n;
l=n*n*n;
text1.setText(n+"的平方是:"+m);
text2.setText(n+"的立方是:"+l);
}
catch (Exception ee)
{
text1.setText("请输入字符");
text2.setText(null);
text3.setText(null);
}
}
public void actionPerformed(ActionEvent e) {
// T