e5_6.java

来自「java 初学者学习实例」· Java 代码 · 共 31 行

JAVA
31
字号
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class E5_6 extends Applet implements TextListener,ActionListener{
	TextArea text1,text2;Button button;
	public void init()
	{ 
	  text1 = new TextArea("",10,10);
	  text2 = new TextArea("",10,10);
	  button = new Button("确定");
	  add(text1);add(text2);add(button);
	  text1.addTextListener(this);
	  button.addActionListener(this);
	}
	public void textValueChanged(TextEvent e)
	{
		if (e.getSource() == text1)
		{
			 text2.setText(text1.getText());
		}
	}
	public void actionPerformed(ActionEvent e)
	{
		if (e.getSource() == button)
		{
			 text2.setText("我按了确定按钮");
		}
		
	}
}

⌨️ 快捷键说明

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