qq_client.java.svn-base
资源名称:QQ.rar [点击查看]
上传用户:hongdaled
上传日期:2007-10-03
资源大小:680k
文件大小:1k
源码类别:
ICQ/即时通讯
开发平台:
Java
- package client;
- import java.net.*;import java.io.*;
- import java.awt.event.*;import java.awt.*;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.JTextArea;
- public class qq_client
- {
- JFrame myframe=new JFrame("client");
- JPanel panelx=new JPanel();
- final TextField input=new TextField(20);
- //加final修饰是为了在内嵌类中访问
- JTextArea display=new JTextArea(5,20);
- public qq_client(String s,int b) throws IOException {
- Socket s1 = new Socket(s,b);
- //连接服务器
- DataInputStream dis = new DataInputStream(s1.getInputStream());
- final DataOutputStream dos = new DataOutputStream(s1.getOutputStream());
- panelx.add(input);
- panelx.add(display);
- myframe.add(panelx);
- new clientthread(dis,display);
- //创建一个接收数据线程
- input.addActionListener(new ActionListener(){
- //用匿名内嵌类处理
- public void actionPerformed(ActionEvent e) {
- try{
- dos.writeUTF("client: "+input.getText());
- //发送数据
- }
- catch(IOException z)
- {
- }
- }
- }
- );
- myframe.setSize(300,300);
- myframe.setVisible(true);
- }
- }