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

📄 206a5ceec5d4001914a2835148eb641d

📁 使用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;
    
    public ServerGUI()
    {
        initPanel();
        this.setContentPane(panel);
        this.setSize(400,600);
    }
    
    void initPanel()
    {
        panel = new JPanel(new BorderLayout());
        if (startButton == null)
            startButton = new JButton("Start!");
        startButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e)
            {
                //..
            }
        });
        if (stopButton == null)
            stopButton = new JButton("Stop!");
        stopButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e)
            {
                //..
            }
        });
        Box buttons = Box.createHorizontalBox();
        buttons.add(startButton);
        buttons.add(Box.createHorizontalStrut(40));
        buttons.add(stopButton);
        
        if (displayPane == null)
        {
            displayArea = new JTextArea();
            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();
    }
}

⌨️ 快捷键说明

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