import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import java.net.*;
import javax.swing.*;

class MyFrame extends JFrame{
    JTextField port;//端口
    JButton start;//启动服务器
    JTextArea content;//聊天框
    JTextField tex;//消息
    JButton say;//发送
    Socket socket;//套接字
    //Myframe类构造函数
    MyFrame(){
        /*this.setTitle("网络通信服务器");
        this.setVisible(true);
        this.setResizable(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);*/
        FlowLayout flowLayout=new FlowLayout();
       setLayout(flowLayout); //设置窗体为流式布局
        setSize(500,460);
        setLocation(500,100);
        JLabel showport=new JLabel("Port:");
        add(showport);//"Port"
        port = new JTextField("8888",15);
        add(port);
        start = new JButton("Start");
        add(start);
        content = new JTextArea(15,50);
        JScrollPane scroll = new JScrollPane(content); //设置滚动条
        add(scroll);
        add(new JLabel("Say:"));
        tex = new JTextField("Hello,this is server.",30);
        add(tex);
        say = new JButton("Say");
        add(say);
        StartListen startListen = new StartListen();
        SayListen sayListen = new SayListen();
        start.addActionListener(startListen); //为按钮 start 注册一个监听器
        say.addActionListener(sayListen); //为按钮 say注册一个监听器
    }

    class StartListen implements ActionListener{
        public void actionPerformed(ActionEvent event){

           start.setEnabled(false);
            try {

                int portnum=Integer.parseInt(port.getText());//端口号
                ServerSocket myserver = new ServerSocket(portnum); // 创建一个服务器套接字对象，形参为端口号
                socket = myserver.accept();
                PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true);// 创建一个打印输出流对象，其形参为从套接字 socket 对象中获取的输出流
                out.println("Connected");//连接响应
                content.append("Client connected"+"\n");
                ServerThread st = new ServerThread(); //创建一个 ServerThread 对象st
                st.start(); //启动一个线程，调用 run（）方法
            } catch (IOException e) {
                System.out.println(e);
            }
        }
    }//start监听器
    class SayListen implements ActionListener{

        public void actionPerformed(ActionEvent event){

            try {
                PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true);// 创建一个打印输出流，形参为从套接字socket 中获取的输出流
                String str=tex.getText();
                if(!str.isEmpty()){
                   out.println(new Date()+"\n"+str); //打印输出日期和发送的消息至客户端
                    content.append(new Date()+" \n Me:"+str+"\n");//将消息显示在jtextarea中
                    out.flush(); //清空缓存区
                }
                tex.setText("");//清空输入栏
            } catch (Exception e) {
                System.out.println(e);
            }
        }
    }//say监听器
    class ServerThread extends Thread{
        ServerThread(){}
        public void run(){
            try {
                BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); //创建一个缓冲输出流，其形参为从套接字 socket 中获取的输入流
                String str;
                while(true){
                    str = in.readLine(); //按行读取
                    content.append( str+"\n");//将输入显示在聊天框中
                }
            } catch (Exception e) {
                System.out.println(e);
            }
        }
    }
}

public class Main{
    public static void main(String[] args){
        MyFrame server = new MyFrame();
        server.setTitle("网络通信服务器");
        server.setVisible(true);
        server.setResizable(false); //设置此窗体是否可由用户调整大小
        server.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置默认关闭操作
    }
}请详细分析这段代码的构建过程