effedemo_1.java

来自「《精通JAVA手机游戏与应用程序设计》随书光盘」· Java 代码 · 共 51 行

JAVA
51
字号

import javax.microedition.lcdui.*;

import javax.microedition.midlet.*;

public class EffeDemo_1 extends MIDlet implements CommandListener {

	private Command exitCommand;

	private TextBox tb;

	public EffeDemo_1() {
		exitCommand = new Command("Exit", Command.EXIT, 1);
		tb = new TextBox("Demo", "", 150, 0);
		tb.addCommand(exitCommand);
		tb.setCommandListener(this);

	}

	protected void startApp() {
		long startTime_1 = System.currentTimeMillis();
		for(int i= 1000000;i>=0;i--){}
		long timeTaken_1 = System.currentTimeMillis() - startTime_1;
		
		long startTime_2 = System.currentTimeMillis();
		for(int j= 0;j<=1000000;j++){}
		long timeTaken_2 = System.currentTimeMillis() - startTime_2;
		
		tb.setString("timeTaken_1:" + String.valueOf(timeTaken_1)
				+"\ntimeTaken_2:" + String.valueOf(timeTaken_2));
		Display.getDisplay(this).setCurrent(tb);
		
	}

	protected void pauseApp() {
		
	}

	protected void destroyApp(boolean arg0) {
		
	}

	public void commandAction(Command c, Displayable d) {
		if (c == exitCommand) {
			destroyApp(false);
			notifyDestroyed();
		}

	}

}

⌨️ 快捷键说明

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