📄 main.java
字号:
/* * This file is part of "The Java Telnet Application". * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * "The Java Telnet Application" is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */package de.mud.jta;import de.mud.jta.event.OnlineStatusListener;import de.mud.jta.event.FocusStatusListener;import de.mud.jta.event.SocketRequest;import de.mud.jta.event.ReturnFocusRequest;import de.mud.jta.event.PrinterJobRequest;import de.mud.jta.event.PageFormatRequest;import java.util.Properties;import java.util.Hashtable;import java.util.Enumeration;import java.io.FileInputStream;import java.io.IOException;import java.net.URL;import java.awt.Frame;import java.awt.Font;import java.awt.PrintJob;import java.awt.Dialog;import java.awt.Label;import java.awt.Button;import java.awt.Color;import java.awt.Component;import java.awt.Menu;import java.awt.MenuBar;import java.awt.MenuItem;import java.awt.MenuShortcut;import java.awt.Toolkit;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;import java.awt.event.KeyEvent;import java.awt.event.FocusListener;import java.awt.event.FocusEvent;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.awt.datatransfer.Clipboard;import java.awt.print.PrinterJob;import java.awt.print.PageFormat;import java.awt.print.Paper;/** * <B>The Java Telnet Application</B><P> * This is the implementation of whole set of applications. It's modular * structure allows to configure the software to act either as a sophisticated * terminal emulation and/or, adding the network backend, as telnet * implementation. Additional modules provide features like scripting or an * improved graphical user interface.<P> * This software is written entirely in Java<SUP>tm</SUP>.<P> * This is the main program for the command line telnet. It initializes the * system and adds all needed components, such as the telnet backend and * the terminal front end. In contrast to applet functionality it parses * command line arguments used for configuring the software. Additionally * this application is not restricted in the sense of Java<SUP>tmp</SUP> * security. * <P> * <B>Maintainer:</B> Matthias L. Jugel * * @version $Id: Main.java,v 2.19 2001/03/10 14:50:40 leo Exp $ * @author Matthias L. Jugel, Marcus Mei遪er */public class Main { private final static int debug = 0; private final static boolean personalJava = false; /** holds the last focussed plugin */ private static Plugin focussedPlugin; /** holds the system clipboard or our own */ private static Clipboard clipboard; public static void main(String args[]) { Properties options = new Properties(); try { options.load(Main.class.getResourceAsStream("/de/mud/jta/default.conf")); } catch(IOException e) { System.err.println("jta: cannot load default.conf"); } String error = parseOptions(options, args); if(error != null) { System.err.println(error); System.err.println("usage: de.mud.jta.Main [-plugins pluginlist] " +"[-addplugin plugin] " +"[-config url_or_file] " +"[-term id] [host [port]]"); System.exit(0); } String cfg = options.getProperty("Main.config"); if(cfg != null) try { options.load(new URL(cfg).openStream()); } catch(IOException e) { try { options.load(new FileInputStream(cfg)); } catch(Exception fe) { System.err.println("jta: cannot load "+cfg); } } final String host = options.getProperty("Socket.host"); final String port = options.getProperty("Socket.port"); final Frame frame = new Frame("jta: "+host+(port.equals("23")?"":" "+port)); // set up the clipboard try { clipboard = frame.getToolkit().getSystemClipboard(); } catch(Exception e) { System.err.println("jta: system clipboard access denied"); System.err.println("jta: copy & paste only within the JTA"); clipboard = new Clipboard("de.mud.jta.Main"); } // configure the application and load all plugins final Common setup = new Common(options); setup.registerPluginListener(new OnlineStatusListener() { public void online() { frame.setTitle("jta: "+host+(port.equals("23")?"":" "+port)); } public void offline() { frame.setTitle("jta: offline"); } }); // register a focus status listener, so we know when a plugin got focus setup.registerPluginListener(new FocusStatusListener() { public void pluginGainedFocus(Plugin plugin) { if(Main.debug > 0) System.err.println("Main: "+plugin+" got focus"); focussedPlugin = plugin; } public void pluginLostFocus(Plugin plugin) { // we ignore the lost focus if(Main.debug > 0) System.err.println("Main: "+plugin+" lost focus"); } }); Hashtable componentList = setup.getComponents(); Enumeration names = componentList.keys(); while(names.hasMoreElements()) { String name = (String)names.nextElement(); Component c = (Component)componentList.get(name); if(options.getProperty("layout."+name) == null) { System.err.println("jta: no layout property set for '"+name+"'"); frame.add("South", c); } else frame.add(options.getProperty("layout."+name), c); } if(!personalJava) { frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { setup.broadcast(new SocketRequest()); frame.setVisible(false); frame.dispose(); System.exit(0); } /* public void windowActivated(WindowEvent evt) { System.out.println("Activated ....."); } public void windowDeactivated(WindowEvent evt) { System.out.println("Deactivated ....."); } public void windowDeiconified(WindowEvent evt) { System.out.println("Deiconified ....."); } public void windowIconified(WindowEvent evt) { System.out.println("Iconified ....."); } public void windowOpened(WindowEvent evt) { System.out.println("Opened ....."); } public void windowClosed(WindowEvent evt) { System.out.println("Closed ....."); } */ }); // add a menu bar Font menufont = (Font)Toolkit.getDefaultToolkit().getDesktopProperty("win.menu.font"); MenuBar mb = new MenuBar(); Menu file = new Menu("郎
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -