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

📄 outname.java

📁 实现文件的由大变小
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;

public class outName extends Frame implements ActionListener{
       Label res;//显示标签
       TextArea input,output;//输入,输出文本域
       Button convert;//键

public outName(){
     super("welcome");//调用父类的构造方法定义窗体标题
     res=new Label("请输入你的名字");
     input=new TextArea(2,5); //初始化‘’
     output=new TextArea(2,15);
     convert =new Button("退出");
     setLayout(new FlowLayout());//指定按流式布局排列部件
     add(res);//显示"请输入你的名字"
     add(input);//输入名字的文本域
     add(output);//输出欢迎词的文本域
     add(convert);//实现退出的键
     this.addWindowListener(new WinAdpt());//窗口事件
    
     convert.addActionListener(this);//给按钮注册监听者
     setSize(400,100);//设置窗体的大小
     show();//让窗体可见
}
public void actionPerformed (ActionEvent e){
     if (e.getSource()==input)//获得文本域的输入串
     output.setText("你好,"+input.getText()+",欢迎你使用Java编程!");//将结果显示在标签处
     else System.exit(0);
}
public static void main (String args[]){
new outName();


}
}
class closeWin extends WindowAdapter//窗体的关闭
{
	public void windowClosing(WindowEvent e)
	{
		Window w=e.getWindow();//获取引发WindowEvent事件的具体窗口对象
                w.dispose(); 
	}
}

⌨️ 快捷键说明

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