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

📄 servergui.java

📁 RemoteWAP is a Remote Administration Tool for any Operating System that can support the Java Virtual
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* *  ServerGUI.java * *  Copyright (C) 2004 Jay Scott * *  This program 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 of the License, or *  (at your option) any later version. * *  This program 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 program (gpl.txt); if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */package ui;import java.awt.Dimension;import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.KeyEvent;import java.io.File;import java.io.IOException;import java.net.MalformedURLException;import java.net.URL;import java.text.Format;import java.text.SimpleDateFormat;import java.util.Date;import javax.swing.BorderFactory;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JComponent;import javax.swing.JEditorPane;import javax.swing.JFileChooser;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTabbedPane;import javax.swing.JTextArea;import javax.swing.JTextField;import javax.swing.JViewport;import javax.swing.UIManager;import javax.swing.border.Border;import javax.swing.border.EtchedBorder;import javax.swing.border.TitledBorder;import com.birosoft.liquid.*;import viewer.LogManager;import server.ServerManager;import config.ConfigManager;/** * This is the main GUI class. *  * @author Jay Scott * @created July 21, 2004 * @version 0.4 */public class ServerGUI extends JPanel implements ActionListener {	/**	 * Status text area to append to and keep the user informed of what is	 * happening with the server.	 */	public static JTextArea StatusText = new JTextArea();	/**	 * Label to show current server status online or offline	 */	public static JLabel lblCurrent = new JLabel();	/* Global variables */	String SelectedFile = null;	String writeLog = null;	/* Miscellaneous objects */	FlowLayout MainLayout = new FlowLayout();	TitledBorder mainTitleBorder;	Border LoweredEtched;	Format TimeFormat;	/* Objects for the Server panel */	JButton btnStartServer = new JButton();	JButton btnRestartServer = new JButton();	JButton btnStopServer = new JButton();	/* Objects for the Log Viewer panel */	JButton btnViewLog = new JButton();	JButton btnDeleteLog = new JButton();	JButton btnSelectFile = new JButton();	JTextField txtFile = new JTextField(35);	JTextArea fileViewer = new JTextArea();	/* Objects for the Configure panel */	JButton btnUpdate = new JButton();	JTextField configPort = new JTextField(10);	JTextField configPasscode = new JTextField(10);	JTextField configLogPath = new JTextField(12);	/* Our own objects */	LogManager log = new LogManager();	ConfigManager cfg = new ConfigManager();	ServerManager server = new ServerManager();	/**	 * Constructor for the ServerGUI object	 */	public ServerGUI() {				/* Set look and feel */		try {			UIManager.setLookAndFeel(new LiquidLookAndFeel());			}		catch (Exception e) {}						JTabbedPane ServerTabbedPane = new JTabbedPane();		Date date = new Date();		TimeFormat = new SimpleDateFormat("hh:mm:ss a");		/* Assign the images to a ImageIcon then display them in the tabs */		ImageIcon WelcomeIcon = createImageIcon("home.gif");		ImageIcon ServerIcon = createImageIcon("server.gif");		ImageIcon LogIcon = createImageIcon("logs.gif");		ImageIcon ConfigIcon = createImageIcon("config.gif");		ImageIcon HelpIcon = createImageIcon("help.gif");		/* Set properties of the border */		LoweredEtched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);		/* 		 * Here we build the welcome tab. We call on the makeWelcome function		 * which returns a panel which we then add to the welcome tab.		 */		JComponent WelcomePanel = makeWelcome();		ServerTabbedPane.addTab("  Welcome", WelcomeIcon, WelcomePanel,				"Welcome to RemoteWAP");		WelcomePanel.setPreferredSize(new Dimension(680, 400));		ServerTabbedPane.setMnemonicAt(0, KeyEvent.VK_1);		/* Create the Server tab with the same extras as above */		JComponent ServerPanel = makeServer();		ServerPanel.setPreferredSize(new Dimension(680, 400));		ServerTabbedPane.addTab("  Server", ServerIcon, ServerPanel,				"Server Manager");		ServerTabbedPane.setMnemonicAt(1, KeyEvent.VK_2);		/* Create the Logs tab with the same extras as above */		JComponent LogPanel = makeLogs();		LogPanel.setPreferredSize(new Dimension(680, 400));		ServerTabbedPane.addTab("  Logs", LogIcon, LogPanel, "Log Manager");		ServerTabbedPane.setMnemonicAt(2, KeyEvent.VK_3);		/* Create the Configure tab with the same extras as above */		JComponent ConfigPanel = makeConfig();		ConfigPanel.setPreferredSize(new Dimension(680, 400));		ServerTabbedPane.addTab("  Configure", ConfigIcon, ConfigPanel,				"Config Manager");		ServerTabbedPane.setMnemonicAt(3, KeyEvent.VK_4);		/* Create the Help tab with the same extras as above */		JComponent HelpPanel = makeHelp();		HelpPanel.setPreferredSize(new Dimension(680, 400));		ServerTabbedPane				.addTab("  Help", HelpIcon, HelpPanel, "RemoteWAP Help");		ServerTabbedPane.setMnemonicAt(4, KeyEvent.VK_5);		/* Now add the newly created tabs to the main tab frame */		add(ServerTabbedPane);	}	/**	 * Builds the Welcome pane to add into the tab frame.	 * 	 * @return JPane with the welcome page objects	 */	private JComponent makeWelcome() {		ImageIcon MainLogo = new ImageIcon("images" + File.separatorChar				+ "phones.gif");		JPanel WelcomePanel = new JPanel(false);		JPanel AboutPanel = new JPanel(false);		JLabel lblInfo = new JLabel();		JLabel WelcomeLogo = new JLabel();		MainLayout.setAlignment(FlowLayout.CENTER);		lblInfo				.setText("<html><html><font size='2'><center><br>"						+ "RemoteWAP is a Remote Administration Tool for the linux Operating System "						+ "that runs<br>on the Java Virtual Machine. It has been designed for "						+ "anyone who wishes to have complete control<br> of their OS anywhere by using "						+ "a WAP enabled Mobile Phone. RemoteWAP is developed using<br> Java and WML for "						+ "the client front-end pages. RemoteWAP has a Java Swing-GUI for easy "						+ "control" + "</font></html></center>");		/* Setup the border properties and the title */		mainTitleBorder = BorderFactory.createTitledBorder(LoweredEtched,				"RemoteWAP Project");		AboutPanel.setBorder(mainTitleBorder);		/* Set the properties of the About panel */		AboutPanel.setPreferredSize(new Dimension(670, 120));		AboutPanel.add(lblInfo);		/* Add everything to the main panel and all in the right order */		WelcomeLogo.setIcon(MainLogo);		WelcomePanel.setLayout(MainLayout);		WelcomePanel.add(WelcomeLogo);		WelcomePanel.add(AboutPanel);		/* Return the welcome panel */		return WelcomePanel;	}	/**	 * This builds the Server pane tab	 * 	 * @return JPane with the server tab objects.	 */	public JComponent makeServer() {		FlowLayout StatusLayout = new FlowLayout();		JPanel CurrentPane = new JPanel();		JPanel ServerPanel = new JPanel(false);		JPanel OptionsPane = new JPanel();		JScrollPane StatusPane = new JScrollPane();		String currentTime = getTime();		StatusLayout.setAlignment(FlowLayout.RIGHT);		lblCurrent.setText("<html><font color='red' size='2'>"				+ "SERVER OFFLINE</font></html>");		/* Build the Status Pane panel and scroll text box and set a few properties */		StatusPane.setWheelScrollingEnabled(true);		StatusPane.setViewportView(StatusText);		StatusPane.setPreferredSize(new Dimension(670, 270));		StatusText.setBackground(UIManager.getColor("Panel.background"));		StatusText.setEditable(false);		StatusText.setLineWrap(true);		OptionsPane.setPreferredSize(new Dimension(270, 60));		/* Create and then add the buttons to the Options Pane panel */		btnStartServer.addActionListener(this);		btnStopServer.addActionListener(this);		btnRestartServer.addActionListener(this);		/* Set the properties of the border and the title */		LoweredEtched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);		mainTitleBorder = BorderFactory.createTitledBorder(LoweredEtched,				"Server Options");		OptionsPane.setBorder(mainTitleBorder);		/* Give the buttons names */		btnStartServer.setText("Start");		btnStopServer.setText("Stop");		btnRestartServer.setText("Restart");		/* Get the current server settings */		int tmpPortNumber = cfg.getPortNumber();		String tmpLogPath = cfg.getLogPath();		/* Set a few messages and write to the log */		StatusText.append('[' + currentTime + ']'				+ " - Loading Config File...\n");		StatusText.append('[' + currentTime + ']' + " - Listening on port "				+ tmpPortNumber + '\n');		StatusText.append('[' + currentTime + ']' + " - Saving log files to "				+ tmpLogPath + " Directory\n");		log.writeLogFile(StatusText.getText(), tmpLogPath);		/* Now set the size of the buttons */		btnStartServer.setPreferredSize(new java.awt.Dimension(80, 20));		btnStopServer.setPreferredSize(new java.awt.Dimension(80, 20));		btnRestartServer.setPreferredSize(new java.awt.Dimension(80, 20));		// Add the buttons to the Options Pane */		OptionsPane.add(btnStartServer);		OptionsPane.add(btnStopServer);		OptionsPane.add(btnRestartServer);		OptionsPane.setLayout(StatusLayout);		// Create the Current Pane */ 		CurrentPane.add(lblCurrent);		// Now added it all to the main Server Pane and then return it */		ServerPanel.setLayout(MainLayout);		ServerPanel.add(OptionsPane);		ServerPanel.add(StatusPane);		ServerPanel.add(CurrentPane);		return ServerPanel;	}	/**	 * This builds the Log tab pane	 * 	 * @return JPane of the log pane for the tab frame	 */	private JComponent makeLogs() {		JPanel LogPanel = new JPanel(false);		JPanel SelectPane = new JPanel();		JScrollPane LogViewer = new JScrollPane();		JLabel lblSelect = new JLabel();		TitledBorder ConfigTitle;		MainLayout.setAlignment(FlowLayout.CENTER);		/* Set the border properties */		ConfigTitle = BorderFactory.createTitledBorder(LoweredEtched,				"Select File");		SelectPane.setBorder(ConfigTitle);		/* Set some panel properties */		LogViewer.setViewportView(fileViewer);		LogViewer.setPreferredSize(new Dimension(650, 280));		SelectPane.setPreferredSize(new Dimension(620, 80));		/* Set some properties of the log viewer */		fileViewer.setBackground(UIManager.getColor("Panel.background"));		fileViewer.setEditable(false);		fileViewer.setLineWrap(true);		/* Set the text of some objects */

⌨️ 快捷键说明

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