example7_5.java.bak
来自「不错的教程 适合中高级人员的使用」· BAK 代码 · 共 55 行
BAK
55 行
import java.awt.*;
import java.awt.event.*;
public class Example7_5
{
public static void main(String[] args)
{
HisWindow win=new HisWindow();
}
}
class HisWindow extends Frame
{
TextField text1,text2,text3;
HisWindow()
{
text1=new TextField(10);
text2=new TextField(10);
text3=new TextField(10);
setLayout(new FlowLayout());
add(text1);add(text2);add(text3);
Policeman police=new Policeman();
text1.addActionListener(police);
text2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String number=e.getActionCommand();
int n=Integer.parseInt(number);
int m=n*n;
text2.setText(n+"的平方是"+m);
}
}
);
setBounds(100,100,150,150);
setVisible(true);
validate();
}
class Policeman implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String number=e.getActionCommand();
int n=Integer.parseInt(number);
int m=n*n*n;
text3.setText(n+"的平方是:"+m);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?