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

📄 textfieldexample.java

📁 JAVA SE6 全方位学习 朱仲杰 编著 机械工业出版社出版
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;

public class TextFieldExample implements TextListener, ActionListener
{
	Frame f;
	Label lb;
	TextField tf;
	
	public static void main(String argv[])
	{
		new TextFieldExample();
	}
	
	public TextFieldExample()
	{
		f = new Frame ("TextField Example");
		f.setLayout(new GridLayout(2,1));
		
		tf = new TextField("", 20);
		tf.addTextListener(this);
		tf.addActionListener(this);
		
		lb = new Label();
		
		f.add(tf);
		f.add(lb);
		f.pack();
		f.setVisible(true);
	}
	
	public void textValueChanged(TextEvent e)
	{
		lb.setText(tf.getText());
	}
	
	public void actionPerformed(ActionEvent e)
	{
		tf.setText("");
	}
}

⌨️ 快捷键说明

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