📄 application.java
字号:
package edu.odu.cs.zeil.AlgAE;import java.applet.Applet;import java.util.Hashtable;import java.io.BufferedReader;import java.io.FileReader;import java.io.Reader;import java.io.Writer;import java.io.InputStream;import java.io.OutputStream;import java.awt.Frame;import edu.odu.cs.zeil.AlgAE.MessageIO;/** * Contains information specific to a single instance of a running * application, whether that program is launched as an applet or as a * standalone. * * @author Steven J Zeil **/public class Application{ public Applet applet; public Thread timerThread; public Thread dispatcherThread; public Thread msgReaderThread; public Messages msgs; public MessageIO msgIO; public Reader inReader; public Writer outWriter; public InputStream inStream; public OutputStream outStream; public Writer logStream; public Writer debugOut; public Frame dataWindow; private Frame dummyWindow; public Application () { msgs = new Messages(); applet = null; timerThread = null; dispatcherThread = null; msgReaderThread = null; msgIO = null; inReader = null; outWriter = null; inStream = null; outStream = null; logStream = null; debugOut = null; dataWindow = null; dummyWindow = null; } public Frame dialogParent() { if (dataWindow != null) return dataWindow; else { if (dummyWindow == null) dummyWindow = new Frame("AlgAE"); dummyWindow.setVisible (true); return dummyWindow; } } public void dialogDone() { if (dummyWindow != null) dummyWindow.setVisible (false); } public void exit (int code) { if (timerThread != null) try { timerThread.stop(); } catch (Throwable e) {} if (dispatcherThread != null) try { dispatcherThread.stop(); } catch (Throwable e) {} if (msgReaderThread != null) try { msgReaderThread.stop(); } catch (Throwable e) {} if (msgIO != null) try { msgIO.close(); } catch (Throwable e) {} if (inReader != null) try { inReader.close(); } catch (Throwable e) {} if (outWriter != null) try { outWriter.close(); } catch (Throwable e) {} if (inStream != null) try { inStream.close(); } catch (Throwable e) {} if (outStream != null) try { outStream.close(); } catch (Throwable e) {} if (logStream != null) try { logStream.close(); } catch (Throwable e) {} if (debugOut != null) try { debugOut.close(); } catch (Throwable e) {} if (dataWindow != null) try { dataWindow.setVisible(false); } catch (Throwable e) {} if (dummyWindow != null) try { dummyWindow.setVisible(false); } catch (Throwable e) {} if (applet == null) { System.exit (code); } } public boolean isAnApplet () { return applet != null; } public static Hashtable parseCommandLine(String[] args) { Hashtable arguments = new Hashtable(); for (int i = 0; i < args.length; i +=2) { String param = args[i]; if (param.charAt(0) == '@') { String extensionFileName = param.substring(1); BufferedReader moreParameters = null; try { moreParameters = new BufferedReader (new FileReader (extensionFileName)); } catch (java.io.FileNotFoundException e) { System.out.println ("***Error: Could not open file " + extensionFileName); System.exit(-1); } String paramName; try { while ((paramName = moreParameters.readLine()) != null) { paramName = paramName.trim().toLowerCase(); if (paramName.length() > 0) { String paramValue = moreParameters.readLine(); if (paramValue == null) { System.out.println ("***Error in " + extensionFileName + ": no value for " + paramName); System.exit (-1); } arguments.put (paramName, paramValue.trim()); } } } catch (java.io.IOException e) { System.out.println ("***Error in " + extensionFileName + ": " + e); System.exit (-1); } } else { if (param.charAt(0) == '-') param = param.substring(1); arguments.put (param.toLowerCase(), args[i+1]); } } return arguments; } public String toString() { return "Application: " + super.toString() + " msgs=" + msgs; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -