⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example7_5.java.bak

📁 不错的教程 适合中高级人员的使用
💻 BAK
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -