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

📄 ch9ex_2.java

📁 java练习程序
💻 JAVA
字号:
//import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*
public class ch9Ex extends Applet
{
  static Button tom,jerry;
  static TextField text;
  {
  	Frame f=new Frame("OK");
  	f.setSize(200,200);
  	f.setVisible(true);
  	Dog hans=new Dog();
  	tom=new Button("tom");
  	jerry=new Button("jerry");
  	text=new TextField(10);
  	tom.addActionListener(hans);
  	f.add(tom,"North");
  	f.add(jerry,"South");
  	f.add(text,"Center");
  	f.pack();
  }
}
*/
public class ch9Ex_2
{
  static Button tom,jerry;
  static TextField text;
  public static void main(String args[])
  {
  	Frame f=new Frame("OK");
  	f.setSize(200,200);
  	f.setVisible(true);
  	Dog hans=new Dog();
  	tom=new Button("tom");
  	jerry=new Button("jerry");
  	text=new TextField(10);
  	tom.addActionListener(hans);
  	f.add(tom,"North");
  	f.add(jerry,"South");
  	f.add(text,"Center");
  	f.pack();
  }
}

class Dog implements ActionListener
{
	ch9Ex boy=new ch9Ex();
	public void actionPerformed(ActionEvent e)
	{
		if(e.getSource()==boy.tom)
		{
			boy.jerry.setLabel("I love the game!");
			boy.text.setText("you are welcom!");
		}
  	}	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -