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

📄 ch10ex6.java

📁 JAVA程序设计 丁岳伟 彭敦陆编 高等教育出版社 第7---11章程序
💻 JAVA
字号:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Frame5 extends JFrame{
	JTextField t1=new JTextField(15);
	JTextArea t2=new JTextArea(11,15);
	JLabel label=new JLabel("Enter text content");
	Container cp;
	public Frame5(){
		super();
		setTitle("Text/Area Field");
		cp=getContentPane();
		cp.setLayout(new FlowLayout());
		cp.add(label);
		cp.add(t1);
		cp.add(t2);
		t1.addActionListener(new ActionListenerT1());
		setSize(300,300);
		setLocation(50,50);
		addWindowListener(new WindowDestroyer());
	}
	class ActionListenerT1 implements ActionListener{
		public void actionPerformed(ActionEvent e){
			String s=t1.getText();
			if(t2.getLineCount()<10){
				t1.setText("");
				t2.append(s+"\n");
			}
		}
	}
}
public class ch10ex6{
	public static void main(String args[]){
		Frame5 win=new Frame5();
		win.setVisible(true);
	}
}
class WindowDestroyer extends WindowAdapter{
	public void windowClosing(WindowEvent e){
		System.exit(0);
	}
}

⌨️ 快捷键说明

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