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

📄 helloworld.java

📁 javaME useful code with the J2ME helpful learning cla
💻 JAVA
字号:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class HelloWorld extends MIDlet implements CommandListener {
	//声明一个Command对象
	private Command exitCommand;
	private TextBox tb;
	public HelloWorld() {
//创建exitCommand对象
		exitCommand = new Command("Exit", Command.EXIT, 1);
		tb = new TextBox("Hello MIDlet", "Hello,World!", 15, 0);
	}
	protected void startApp() throws MIDletStateChangeException {
		Display.getDisplay(this).setCurrent(tb);
		//向TextBox添加Command,并注册CommandListener
		tb.addCommand(exitCommand);
		tb.setCommandListener(this);
	}
	protected void pauseApp() {
	}
	protected void destroyApp(boolean c) throws MIDletStateChangeException {
		System.out.println("destroyApp");
	}
	public void commandAction(Command c, Displayable d) {
	//如果一个Command对象被按下,那么它将作为参数传递给commandAction()
		if (c == exitCommand) {
			try {
				destroyApp(false);
			} catch (MIDletStateChangeException exception) {
				System.out.println("MIDletStateChangeException");
			}
			notifyDestroyed();
		}
	}
}

⌨️ 快捷键说明

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