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

📄 logform.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.Item;import javax.microedition.lcdui.Spacer;import javax.microedition.lcdui.StringItem;public class LogForm extends Form implements CommandListener{		private long sentByte = 0;	private long recvdByte = 0;		long getSentByte() {		return sentByte;	}	long addSentByte(int b) {		sentByte += b;		return sentByte;	}	long getRecvdByte() {		return recvdByte;	}	long addRecvdByte(int b) {		recvdByte += b;		return recvdByte;	}		// opeiton metus	private Command[] command = new Command[2];		// constructor	LogForm() {		super(HiisiMIDlet.hiisiMIDlet.proxyName);				totalLog(0, 0);				command[0] = new Command("Back", Command.EXIT, 1);		command[1] = new Command("Clear", Command.SCREEN, 2);		addCommand(command[0]);		addCommand(command[1]);		setCommandListener(this);	}		// adds HTTP log	synchronized void log(String msg) {		int logSize = size();		if(logSize > 6 && !HiisiMIDlet.settingForm.isLogEnable()) {			for(int i = logSize; i > 6; i--) delete(i - 1);		}		insert(2, new StringItem("", msg));	}		synchronized void totalLog(long sent, long recvd) {		if(size() == 0) {			append("Sent: " + sent/1024 + "KB, Recvd.: " + recvd/1024 + "KB\n");			Spacer spacer = new Spacer(5, 5);			spacer.setLayout(Item.LAYOUT_2|Item.LAYOUT_NEWLINE_AFTER);			append(spacer);		} else {			set(0, new StringItem("","Sent: " + sent/1024 + "KB, Recvd.: " + recvd/1024 + "KB\n"));		}	}		// comfirmation for delete log	private void makeConfirmationAlert() {		final Command[] cmd = new Command[2];		Alert confirm = new Alert("Clear log",			"You are about to delete your entire proxy log. Do you wish to continue?", null, AlertType.WARNING);		confirm.setTimeout(Alert.FOREVER);		cmd[0] = new Command("Yes", Command.OK, 1);		cmd[1] = new Command("No", Command.CANCEL, 2);		confirm.addCommand(cmd[0]);		confirm.addCommand(cmd[1]);		confirm.setCommandListener(			new CommandListener() {				public void commandAction(Command c, Displayable d) {					if(c == cmd[0]) {						deleteAll();						totalLog(getSentByte(), getRecvdByte());					}					Display.getDisplay(HiisiMIDlet.hiisiMIDlet).setCurrent(HiisiMIDlet.logForm);				}			}		);		Display.getDisplay(HiisiMIDlet.hiisiMIDlet).setCurrent(confirm);	}		// actions of option menus	public void commandAction(Command c,Displayable d) {		// back		if(c == command[0]) {			Display.getDisplay(HiisiMIDlet.hiisiMIDlet).setCurrent(HiisiMIDlet.mainForm);		}		// clears log		if(c == command[1]) {			makeConfirmationAlert();		}	}}

⌨️ 快捷键说明

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