main.java

来自「piweurrrrq i o fhsadhfka fd dskajc zxkjc」· Java 代码 · 共 79 行

JAVA
79
字号
/* * Copyright (c) 2000 Lyrisoft Solutions, Inc. * Used by permission */package com.lyrisoft.chat.client;import com.lyrisoft.chat.Translator;import com.lyrisoft.chat.server.local.*;import com.lyrisoft.chat.client.gui.IChatGUIFactory;import java.io.IOException;import java.util.Properties;/** * Main class for standalone-client execution. * Command-line args: [host] [port] * * Immediately instantiates a new Client object, which gets the client going */public class Main {    public static void main(String[] args) {        String host = null;        int port = 0;        try {            host = args[0];            port = Integer.parseInt(args[1]);        }        catch (Exception e) {            showUsageAndQuit();        }        IChatGUIFactory factory = null;        UserCommands userCommands = null;        CommandProcessorLocal commandProcessor = null;        Client client = new Client(host, port);        try {            String guiFactoryName = System.getProperty("guiFactory", "com.lyrisoft.chat.client.gui.awt102.GUIFactory");            factory = (IChatGUIFactory)Class.forName(guiFactoryName).newInstance();            Properties p = client.getProperties("commandProcessors.properties");            if (p != null) {                commandProcessor = new CommandProcessorLocal(p);            } else {                throw new Exception("Could not load commandProcessors.properties");            }            p = client.getProperties("userCommands.properties");            if (p != null) {                userCommands = new UserCommands(p);            } else {                throw new Exception("Could not load userCommands.properties");            }            p = client.getProperties("messages.properties");            initTranslator(p);        }        catch (Exception e) {            e.printStackTrace();            System.exit(1);        }        client.setAttribute("guiFactory", factory);        client.setAttribute("userCommands", userCommands);        client.setAttribute("commandProcessor", commandProcessor);        client.init();        client.getGUI().showLogin();    }    protected static void initTranslator(Properties p) {        Translator.init(p);    }    static void showUsageAndQuit() {        System.err.println("usage: java com.lyrisoft.chat.client.Main host port");        System.exit(1);    }}

⌨️ 快捷键说明

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