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

📄 textexample.java

📁 Java程序设计清华出版课件源码答案共十四章
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;

public class TextExample
	implements ActionListener,TextListener {
	Frame f;
	TextField tf1;
	TextArea ta1,ta2;

	static public void main(String args[]) {
		TextExample te = new TextExample();
		te.go();
	}

	public void go() {
		f = new Frame("Text Example");
		f.setLayout( new FlowLayout() );

		tf1 = new TextField("Init",20);
		tf1.addActionListener(this);
		tf1.addTextListener(this);

		ta1 = new TextArea("Initial text",4,30);
		ta1.addTextListener(this);
		ta2 = new TextArea("Only horizontal scrollbar ",4,30,
		TextArea.SCROLLBARS_HORIZONTAL_ONLY);

		f.add(tf1);
		f.add(ta1);
		f.add(ta2);
		f.setSize(300,300);
		f.setVisible(true);
	}

	public void actionPerformed(ActionEvent e) {
		ta2.append("\nActionPerformed");
	}

	public void textValueChanged(TextEvent e) {
		ta2.append("\nTextValueChanged");
	}
}

⌨️ 快捷键说明

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