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

📄 mainform.java

📁 蓝牙上网 j2me的源代码
💻 JAVA
字号:
package Hiisi;import javax.microedition.lcdui.Alert;import javax.microedition.lcdui.AlertType;import javax.microedition.lcdui.Command;import javax.microedition.lcdui.CommandListener;import javax.microedition.lcdui.Display;import javax.microedition.lcdui.Displayable;import javax.microedition.lcdui.Form;import javax.microedition.lcdui.List;public class MainForm extends Form implements CommandListener{	// main menues	private Command[] command = new Command[6];		// constructor	MainForm() {		super(HiisiMIDlet.hiisiMIDlet.proxyName);				command[0] = new Command("Exit", Command.EXIT, 1);		command[1] = new Command("Restart", Command.SCREEN, 2);		command[2] = new Command("View Log", Command.SCREEN, 3);		command[3] = new Command("Setting", Command.SCREEN, 4);		command[4] = new Command("About", Command.SCREEN, 5);		command[5] = new Command("Exit", Command.SCREEN, 6);		addCommand(command[0]);		addCommand(command[1]);		addCommand(command[2]);		addCommand(command[3]);		addCommand(command[4]);		addCommand(command[5]);		setCommandListener(this);				// Application starts with mode selection.		makeModeSelectionGUI();	}		// message on main	synchronized void log(String msg) {		deleteAll();		append(msg+"\n");	}		// error message on main	synchronized void log(Throwable e) {		log(e.getMessage());	}		// mode selection (bluetooth mode or W-CDMA / GSM mode)	// starts server	// sets SettingForm#gatewayMode	// bluetooth mode: calls BluetoothConnection#startDeviceInquiry()	private void makeModeSelectionGUI() {		final List modes = new List("Select a mode", List.IMPLICIT);		if(HiisiMIDlet.settingForm.getDefaultUrl() != null) {			modes.append("Bluetooth Mode [default]", null);			modes.append("Bluetooth Mode [other]", null);		} else {			modes.append("Bluetooth Mode", null);		}		modes.append("W-CDMA / GSM Mode", null);		modes.setCommandListener(			new CommandListener() {				public void commandAction(Command c, Displayable d) {					Display.getDisplay(HiisiMIDlet.hiisiMIDlet).setCurrent(HiisiMIDlet.mainForm);					if(modes.getString(modes.getSelectedIndex()).equals("Bluetooth Mode [default]")) {						HiisiMIDlet.settingForm.setGatewayMode(HiisiMIDlet.settingForm.BLUETOOTH_MODE);						log("Hiisi Proxy " + HiisiMIDlet.settingForm.getGatewayModeString() + " is idling...");						HiisiMIDlet.bluetoothConnection.setUrl(HiisiMIDlet.settingForm.getDefaultUrl());					}					if(modes.getString(modes.getSelectedIndex()).equals("Bluetooth Mode [other]")							|| modes.getString(modes.getSelectedIndex()).equals("Bluetooth Mode")) {						HiisiMIDlet.settingForm.setGatewayMode(HiisiMIDlet.settingForm.BLUETOOTH_MODE);						log("Hiisi Proxy " + HiisiMIDlet.settingForm.getGatewayModeString() + " is idling...");						HiisiMIDlet.bluetoothConnection.startDeviceInquiry();					}					if(modes.getString(modes.getSelectedIndex()).equals("W-CDMA / GSM Mode")) {						HiisiMIDlet.settingForm.setGatewayMode(HiisiMIDlet.settingForm.WAP_MODE);						log("Hiisi Proxy " + HiisiMIDlet.settingForm.getGatewayModeString() + " is idling...");					}				}			}		);		Display.getDisplay(HiisiMIDlet.hiisiMIDlet).setCurrent(modes);		HiisiMIDlet.gateway.start();	}		// about MIDlet	private void makeAboutAlert() {		Alert about = new Alert("About " + HiisiMIDlet.hiisiMIDlet.proxyName,			HiisiMIDlet.hiisiMIDlet.proxyName + " (" + HiisiMIDlet.hiisiMIDlet.version +"), Created 2007 by Hiisi (hiisi.proxy@gmail.com), Visit http://hiisi-proxy.blogspot.com/ for details.", null, AlertType.INFO);		about.setTimeout(Alert.FOREVER);		Display.getDisplay(HiisiMIDlet.hiisiMIDlet).setCurrent(about);	}		// actions of main menus	public void commandAction(Command c,Displayable d) {		// exits MIDlet		if(c == command[0]) {			HiisiMIDlet.gateway.exitGateway();			HiisiMIDlet.hiisiMIDlet.exitApp();		}		// restarts server		if(c == command[1]) {			HiisiMIDlet.gateway.running = false;			HiisiMIDlet.gateway.exitGateway();			log("Restarting...");			try {				Thread.sleep(1 * 1000);			} catch(InterruptedException e) {			}			HiisiMIDlet.gateway = new Gateway();			HiisiMIDlet.gateway.running = true;			HiisiMIDlet.gateway.start();		}		// displays HTTP log		if(c == command[2]) {			HiisiMIDlet.logForm.totalLog(HiisiMIDlet.logForm.getSentByte(), HiisiMIDlet.logForm.getRecvdByte());			Display.getDisplay(HiisiMIDlet.hiisiMIDlet).setCurrent(HiisiMIDlet.logForm);		}		// settings		if(c == command[3]) {			HiisiMIDlet.settingForm.uncheckCheckConnection();			Display.getDisplay(HiisiMIDlet.hiisiMIDlet).setCurrent(HiisiMIDlet.settingForm);		}		// about MIDlet		if(c == command[4]) {			makeAboutAlert();		}		// exits MIDlet		if(c == command[5]) {			HiisiMIDlet.gateway.exitGateway();			HiisiMIDlet.hiisiMIDlet.exitApp();		}	}}

⌨️ 快捷键说明

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