p.add(t1);//添加t1进面板p中
 p.add(tt);//添加显示获取到的本机的IP地址用于给不同一台电脑的客户端登陆
 tt.setText("服务器的IP地址为:"+adr.getAddress());
 p.add(jj1);
 p.add(jsp);
 p1.add(jsp1);//添加t2进去面板p1
 t2.setBackground(new Color(120,195,188));
 p2.add(jj);  //添加显示在线人数的文本框jj
 p2.add(jb);  //添加显示在线人数文本域
 
 this.getContentPane().add(p2,  BorderLayout.NORTH);//把面板p2放在JFrame的上方
 this.getContentPane().add(p1,  BorderLayout.CENTER);//把面板p1放在JFrame的中间方
 this.getContentPane().add(p,  BorderLayout.SOUTH);//把面板p放在JFrame的下方
 this.setVisible(true);//设置JFrame为可见
    setResizable(false);//设置JFrame框架不可以改变大小 
 this.setDefaultCloseOperation(EXIT_ON_CLOSE);//关闭窗口方法
 }
 class Tevent implements ActionListener{
  public void actionPerformed(ActionEvent e) {
      tt1=t1.getText();     
      t1.setText("");
      t2.setText(t2.getText()+"\n"+"服务器:"+tt1);//把消息显示在服务器面板t2文本域中
     try {
   dd.writeUTF(tt1);
   str=tt1;
   
  } catch (IOException e1) {
   
   e1.printStackTrace();
  }
  }
  
 }
 //用Address类获取本地服务器的IP地址,不同一台电脑的客户端就靠此ip登陆
 class Address {论文网http://www.chuibin.com/
        private String ip;
        public String getAddress(){
        try{
            InetAddress address = InetAddress.getLocalHost();
            ip= address.getHostAddress().toString();
        }catch(Exception e){
            ip = "无法获得IP";
        }
        return ip;
        }
    }
 public static void main(String[] args) {
  new Server().start();//在主方法mian调用start()
  
 }
 
 public void start() {
  try {
   ss = new ServerSocket(8888);//监听端口号为8888
   started = true;
  } catch (IOException e) {
   e.printStackTrace(); JScrollPane jsp=new JScrollPane(t3); 
  JScrollPane jsp1=new JScrollPane(t2); 
  JPanel p=new JPanel();//定义一个p面板
  JPanel p1=new JPanel();
  JPanel p2=new JPanel();
  String tt1=null;
  String str=null;//用于接受存储客户端的字符串变量
  boolean Listening=true;int number=0;
  DataOutputStream dd=null;
   
 Server(){
 t2.setText("显示客户端聊天的内容:");
 this.setTitle("服务器端已经启动........");
 this.setLayout(new FlowLayout());//定义JFrame的布局管理器为FlowLayout类型
    this.setSize(580,520);//定义JFrame的大小
    this.setLocation(300,200);//定义JFrame的位置坐标
 p.setBackground(new Color(10,150,92));//定义面板p的背景颜色
 t1.addActionListener(new Tevent());
 p.add(t1);//添加t1进面板p中
 p.add(tt);//添加显示获取到的本机的IP地址用于给不同一台电脑的客户端登陆
 tt.setText("服务器的IP地址为:"+adr.getAddress());
 p.add(jj1);原文请找腾讯752018766
 p.add(jsp);
 p1.add(jsp1);//添加t2进去面板p1
 t2.setBackground(new Color(120,195,188));
 p2.add(jj);  //添加显示在线人数的文本框jj
 p2.add(jb);  //添加显示在线人数文本域
 
 this.getContentPane().add(p2,  BorderLayout.NORTH);//把面板p2放在JFrame的上方
 this.getContentPane().add(p1,  BorderLayout.CENTER);//把面板p1放在JFrame的中间方
 this.getContentPane().add(p,  BorderLayout.SOUTH);//把面板p放在JFrame的下方
 this.setVisible(true);//设置JFrame为可见
    setResizable(false);//设置JFrame框架不可以改变大小 
 this.setDefaultCloseOperation(EXIT_ON_CLOSE);//关闭窗口方法
 }
 class Tevent implements ActionListener{
  public void actionPerformed(ActionEvent e) {
      tt1=t1.getText();     
      t1.setText("");
      t2.setText(t2.getText()+"\n"+"服务器:"+tt1);//把消息显示在服务器面板t2文本域中
     try {
   dd.writeUTF(tt1);
   str=tt1;
   
  } catch (IOException e1) {
   
   e1.printStackTrace();
  }
  }
  
 }
 //用Address类获取本地服务器的IP地址,不同一台电脑的客户端就靠此ip登陆
 class Address {论文网http://www.chuibin.com/
        private String ip;
        public String getAddress(){
        try{
            InetAddress address = InetAddress.getLocalHost();
            ip= address.getHostAddress().toString();
        }catch(Exception e){
            ip = "无法获得IP";
        }
        return ip;
        }
    }
 public static void main(String[] args) {
  new Server().start();//在主方法mian调用start()
  
 }
 
 public void start() {
  try {
   ss = new ServerSocket(8888);//监听端口号为8888
   started = true;
  } catch (IOException e) {
   e.printStackTrace();