⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e08634e7c7d4001914a2835148eb641d

📁 使用TCP和UDP协议
💻
字号:
/*
 * Created on 2005-6-4
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package server;

/**
 * @author Administrator
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class ServerGUI extends JFrame{
    int tcpPort = 1234,
    	udpPort = 1235;
    JPanel panel = null;
    JTextArea displayArea = null;
    JScrollPane displayPane = null;
    JButton startButton = null,
    		stopButton = null;
    TCPThread tcpThread = null;
    
    public ServerGUI()
    {
        initFrame();
        initPanel();
        this.setContentPane(panel);
    }
    
    void initFrame()
	{
	    this.addWindowListener(new WindowAdapter() {
	        public void windowClosing(WindowEvent frameEvent)
	        {
//	            tcpThread.finalized();
	            System.exit(0);
	        }
	    });
		this.setSize(500, 550);
		this.setTitle("\"别问我是谁,请与我面对\"服务器");
	}
    
    void initPanel()
    {
        panel = new JPanel(new BorderLayout());
        if (startButton == null)
            startButton = new JButton("启动!");
        startButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e)
            {
                //..
            }
        });
        if (stopButton == null)
            stopButton = new JButton("停止!");
        stopButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e)
            {
                //..
            }
        });
        Box buttons = Box.createHorizontalBox();
        buttons.add(Box.createHorizontalGlue());
        buttons.add(startButton);
        buttons.add(Box.createHorizontalGlue());
        
        buttons.add(stopButton);
        buttons.add(Box.createHorizontalGlue());
        
        if (displayPane == null)
        {
            displayArea = new JTextArea();
            displayArea.setLineWrap(true);
            displayPane = new JScrollPane(displayArea, 
        			JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
        			JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        }
        
        panel.add(BorderLayout.NORTH, buttons);
        panel.add(BorderLayout.CENTER, displayPane);
    }
    public static void main(String[] args)
    {
        ServerGUI serverGUI = new ServerGUI();
        serverGUI.show();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -