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

📄 main.java

📁 主要是对串口驱动的的一些控制源码!!! 在下载javacomm20-win32.zip后就可以使用。
💻 JAVA
字号:
package de.fhm.jkf.launch.cl;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.border.TitledBorder;

import de.fhm.jkf.launch.clsv.LaunchLogger;
import de.fhm.jkf.launch.clsv.LogLevel;

/**
 * @author Theodor Willax
 *
 * <br><br><center><table border="1" width="80%"><hr>
 * <strong><a href="http://jkf.sourceforge.net">The JKF Project</a></strong>
 * <p>
 * Copyright (C) 2002 by Theodor Willax
 * <p>
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * <p>
 * This library 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
 * Lesser General Public License for more details.
 * <p>
 * You should have received a copy of the <a href="http://www.gnu.org/copyleft/lesser.html">
 * GNU Lesser General Public License</a> along with this library; if not, write to
 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA  02111-1307  USA
 * <hr></table></center>
 *
 * <code>Main</code> class of the launcher application.
 */
public class Main extends JFrame implements WindowListener {
	/** The configuration panel for proxy settings. */
	private ProxyConfigurationPanel pcp;

	/** The button panel for starting the remote application. */
	private ButtonBarPanel bbp;

	/**
	 * Sole constructor.
	 */
	public Main() {
		super("JKF Launcher");
		bbp = new ButtonBarPanel(this);
		pcp = new ProxyConfigurationPanel();
		addWindowListener(this);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		Container c = getContentPane();
		c.setLayout(new BorderLayout());
		c.add(pcp, BorderLayout.CENTER);
		c.add(bbp, BorderLayout.SOUTH);
		TextResource res = new TextResource();
		String app =
			res.getString("appName") + " " + res.getString("appVersion");
		TitledBorder title = BorderFactory.createTitledBorder("JKF Launcher");
		JLabel label = new JLabel(app, SwingConstants.CENTER);
		label.setBorder(title);
		c.add(label, BorderLayout.NORTH);
		pack();
		setVisible(true);
	}

	/**
	 * @see java.awt.event.WindowListener#windowOpened(WindowEvent)
	 */
	public void windowOpened(WindowEvent e) {
	}

	/**
	 * Closes the launcher application and also any launched
	 * application. <tt>System.exit(0);</tt> is called.
	 * 
	 * @see java.awt.event.WindowListener#windowClosing(WindowEvent)
	 */
	public void windowClosing(WindowEvent e) {
		System.exit(0);
	}

	/**
	 * @see java.awt.event.WindowListener#windowClosed(WindowEvent)
	 */
	public void windowClosed(WindowEvent e) {
	}

	/**
	 * @see java.awt.event.WindowListener#windowIconified(WindowEvent)
	 */
	public void windowIconified(WindowEvent e) {
	}

	/**
	 * @see java.awt.event.WindowListener#windowDeiconified(WindowEvent)
	 */
	public void windowDeiconified(WindowEvent e) {
	}

	/**
	 * @see java.awt.event.WindowListener#windowActivated(WindowEvent)
	 */
	public void windowActivated(WindowEvent e) {
	}

	/**
	 * @see java.awt.event.WindowListener#windowDeactivated(WindowEvent)
	 */
	public void windowDeactivated(WindowEvent e) {
	}

	/**
	 * Launches the application's main class which is defined in the
	 * application.properties file under the key <tt>mainClass</tt>.
	 * The application is started in an new <code>Thread</code> with it's
	 * own context class loader namely <code>LaunchClassLoader</code>.
	 * 
	 * @see de.fhm.jkf.launch.cl.LaunchClassLoader
	 */
	public void launch() {
		pcp.activateProxySetting();
		TextResource tr = new TextResource();
		Thread t;
		ClassLoader cl;
		try {
			cl =
				new LaunchClassLoader(
					tr.getString("appName"),
					tr.getString("servletURL"),
					getClass().getClassLoader());
			t = new Thread((Runnable) cl, "jkf_launcher");
		} catch (Exception e) {
			System.err.println(
				"Error in " + getClass().getName() + ".launch()");
			new ErrorFrame(e).setVisible(true);
			return; // dont disable the launcher
		}
		t.setContextClassLoader(cl);
		t.start();
		// Now application runs, so wie can become invisible and clean up
		setVisible(false);
		dispose();
		pcp = null;
		bbp = null;
	}

	/**
	 * Calls the <code>clear()</code> method of the local <code>Cache</code>.
	 * 
	 * @return boolean <code>true</code> if <code>Cache</code> could be
	 * cleared, <code>false</code> otherwise.
	 */
	public boolean clearCache() {
		TextResource tr = new TextResource();
		try {
			Cache cache = new Cache(tr.getString("appName"));
			cache.clear();
		} catch (IOException e) {
			LaunchLogger.error("could not clear the cache");
			e.printStackTrace();
			return false;
		}
		return true;
	}

	/**
	 * Tests if the <code>Cache</code> is emtpy or not.
	 * 
	 * @return boolean <code>true</code> if the <code>Cache</code> is
	 * empty, <code>false</code> otherwise.
	 */
	public boolean isCacheEmpty() {
		TextResource tr = new TextResource();
		try {
			Cache cache = new Cache(tr.getString("appName"));
			return cache.isEmtpy();
		} catch (IOException e) {
			e.printStackTrace();
			return false;
		}
	}

	/**
	 * Print's usage information and exits the application.
	 */
	private static final void usage() {
		System.out.println("Usage: jkf_launcher [OPTION]");
		System.out.println();
		System.out.println("\t-debug\t\tenable debugging output");
		System.out.println("\t-info\t\tenable information output");
		System.out.println("\t-error\t\tenable only error output");
		System.out.println("\t-help\t\tprints this help message");
		System.exit(1);
	}

	/**
	 * Starts the launcher application.
	 */
	public static void main(String[] args) {
		if (args.length > 0) {
			if (args[0].endsWith("-debug")) {
				LaunchLogger.setLogLevel(LogLevel.DEBUG);
				System.out.println("debug enabled");
			} else if (args[0].equals("-info")) {
				LaunchLogger.setLogLevel(LogLevel.INFO);
				System.out.println("info enabled");
			} else if (args[0].equals("-error")) {
				LaunchLogger.setLogLevel(LogLevel.ERROR);
				System.out.println("error enabled");
			} else if (args[0].equals("-help")) {
				usage();
			} else {
				System.out.println("Invalid option: " + args[0]);
				usage();
			}
		}
		new Main();
	}
}

⌨️ 快捷键说明

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