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

📄 clientreceive.java

📁 基于netbeans的java桌面应用程序合集
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package org.Adam;import javax.swing.*;import java.io.*;import java.net.*;/** * * @author Administrator */public class ClientReceive extends Thread{    JComboBox jComboBox;    JTextArea jTextArea;    Socket socket;    ObjectInputStream input;    ObjectOutputStream output;    JTextField showStatus;    public ClientReceive(Socket socket,ObjectOutputStream output,ObjectInputStream input,            JComboBox jComboBox,JTextArea jTextArea,JTextField showStatus){        this.input=input;        this.output=output;        this.jComboBox=jComboBox;        this.jTextArea=jTextArea;        this.showStatus=showStatus;        this.socket=socket;    }    public void run(){        while(!socket.isClosed()){            try{                String type=(String)input.readObject();                if(type.equalsIgnoreCase("系统信息")){                    String sysmsg=(String)input.readObject();                    this.jTextArea.append("系统信息"+sysmsg);                }else if(type.equalsIgnoreCase("聊天信息")){                    String message=(String)input.readObject();                    this.jTextArea.append(message);                }else if(type.equalsIgnoreCase("用户列表")){                    String userlist=(String)input.readObject();                    String usernames[]=userlist.split("\n");                    this.jComboBox.removeAllItems();                    this.jComboBox.addItem("ALL");                    for(int i=0;i<usernames.length;i++){                        this.jComboBox.addItem(usernames[i]);                    }                    this.jComboBox.setSelectedIndex(0);                    this.showStatus.setText("在线用户 " + usernames.length + " 人");                }            }catch(Exception e){                e.getMessage();            }                    }    }}

⌨️ 快捷键说明

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