编写一个 Java 应用程序,实现图形界面多人聊天室(多线程实现),要求聊天室窗口标题是 “欢迎使用 XXX 聊天室应用”
这个需要分开运行
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;
public class Client{
public static void main(String args[]) {
Window win=new Window();
win.setBounds(250, 70, 400, 380);
win.setTitle("XXX 的聊天室");
}
}
@SuppressWarnings("serial")
class Window extends JFrame{
JPanel contentPane;
Socket socket;
JTextArea textArea;
JTextField textField;
JTextField textField1;
OutputStream out;
InputStream is;
ReaderListen listener;
public Window() {
init();
try {
socket=new Socket("127.0.0.1",110);
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ReceiveMessage receiver=ne