📄 clientmanager.java~1~
字号:
package com.lu.cheng.xin.qq;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class ClientManager {
ClientFrame frame = null;
String message = null;
ClientBoxManager clientbox = new ClientBoxManager(this);
public ClientManager(ClientFrame frame) {
this.frame=frame;}
public void send(final String s) throws Exception {
if(s!=null){
ChatMsg ms = new ChatMsg(clientbox.getName(),s);
clientbox.out.println(ms.toString());//读取输入 发送数据
clientbox.out.flush();
}else ;
}
public void exit() {
if(!clientbox.running){}
else{
clientbox.out.println(clientbox.getName()+"偷偷地从聊天室遛走了,顺便把你的魂也勾走了...");
clientbox.out.flush();
}
}
}
class ChatMsg {
ChatMsg(String name,String msg){
this.name = name;
this.msg = msg;
}
String name;
String msg;
public String toString(){
return name+"笑哈哈地说:"+msg+"(时间:"+(new Date().toString()+")");
}
}
//Exception in thread "Thread-0" java.lang.OutOfMemoryError: Java heap space
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -