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

📄 client_test.java

📁 QQ聊天程序
💻 JAVA
字号:
package com.tarena.xiaozr.qq;
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;


public class Client_test
  implements ActionListener
{
  Frame f;
  TextField tf;
  public Client_test(){
  	f = new Frame("welcome");
  	f.setLocation(300,300);
      tf = new TextField("",20);
      Label l = new Label("请输入用户名称");
      f.add(l,"North");
      f.add(tf);
      tf.addActionListener(this);
      f.pack();
      f.show();
      f.addWindowListener(new WindowAdapter(){
  		//点关闭以后先通知服务器,然后将客户端刷新显示的线程关闭
  		public void windowClosing(WindowEvent e){
  			try{
  				Thread.sleep(1000);
  			}catch(Exception ee){
  				ee.printStackTrace();
  			}
  			System.exit(1);
  		}
  	});
  }
  public void actionPerformed(ActionEvent e){
  	String tmp = tf.getText();
  	f.dispose();
  	new Client(tmp);
  }
  public static void main(String args[]) throws Exception
  {
      new Client_test();
	  
  }
}

⌨️ 快捷键说明

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