info_server.java

来自「《Java程序设计实践教程》代码」· Java 代码 · 共 76 行

JAVA
76
字号
/***************************************************
*  程序文件名称: Info_server.java
*  功能:显示用户操作窗口界面
***************************************************/
import java.awt.*;
import java.awt.event.*;

public class Info_server extends Frame 
{
    TextArea info;
    RunServer server;
    
    public static void main(String[] args)
     {
        // Create application frame.
        Info_server frame = new Info_server();
        // Show frame
        frame.setVisible(true);
     }
    
     public Info_server() 
      {          
        MenuBar menuBar = new MenuBar();
        Menu menuFile = new Menu();
        MenuItem menuFileExit = new MenuItem();
        info = new TextArea("Start Server...");
        
        menuFile.setLabel("System");
        menuFileExit.setLabel("Exit");
        info.setFont(new Font("Default",Font.BOLD,30));
        info.setEditable(false);
        // Add action listener.for the menu button
        menuFileExit.addActionListener
        (
         new ActionListener()
          {
           public void actionPerformed(ActionEvent e)
            {
              Info_server.this.windowClosed();
            }
          }
        ); 
        menuFile.add(menuFileExit);
        menuBar.add(menuFile);
        this.add(info);
        setTitle("Info_server");
        setMenuBar(menuBar);
        setSize(new Dimension(400, 400));
        
        // Add window listener.
        this.addWindowListener
        (
          new WindowAdapter()
           {
            public void windowClosing(WindowEvent e)
             {
                Info_server.this.windowClosed();
              }
            }
        );  
        
        server = new RunServer(info);
        server.start();
    }
    
    /**
     * Shutdown procedure when run as an application.
     */
    protected void windowClosed()
     {	
    	// TODO: Check if it is safe to close the application
        // Exit application.
        System.exit(0);
     }    
}

⌨️ 快捷键说明

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