回答我,立即给分!!!!!!!!!!!!!!!(1)
import java.io.*;
import java.net.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Server extends JFrame
{
private JTextField field;
private JTextArea area;
private JScrollPane scrollPane;
private JButton button;
private ServerSocket server_1;
private Socket server_2;
private ObjectOutputStream out;
private ObjectInputStream in;
public Server()
{
super( "我的第一个聊天程序 ");
field = new JTextField(30);
area = new JTextArea(10,10);
scrollPane = new JScrollPane(area);
button = new JButton( "提交 ");
getContentPane().add(field,BorderLayout.NORTH);
getContentPane().add(scrollPane,BorderLayout.CENTER);
getContentPane().add(button,BorderLayout.SOUTH);
setSize(300,300);
setVisible(true);
connect();
}
public void connect()
{
try{
server_1 = new ServerSocket(4700);
area.append( "服务器启动,等待连接 ");
server_2 = server_1.accept();
area.append( "\n连接成功,可以进行通讯了 ");
out = new ObjectOutputStream(server_2.getOutputStream());
in = new ObjectInputStream(server_2.getInputStream());
out.flush();
Mread();
}catch(Exception e){}
}
public void Mread()