helloworld.java
来自「j2me」· Java 代码 · 共 55 行
JAVA
55 行
// include the MIDlet supper class
import javax.microedition.midlet.MIDlet;
// include the GUI libraries of MIDP
import javax.microedition.lcdui.*;
/*
* 1. All MIDlet applications must extend the MIDlet class.
* 2. CommandListener is the event-handling interface of the
* high-level GUI API. More details can be found in the
* Chapter 5 and 6.
*/
public class HelloWorld extends MIDlet implements CommandListener{
// define the GUI components of HelloWorld
private Display display;
private TextBox mainScreen = null;
private Command exit = new Command("exit", Command.EXIT, 2);
// define the no-argument constructor
public HelloWorld() {
display = Display.getDisplay(this);
mainScreen = new TextBox("HelloWorld", "Hello World", 512,0);
mainScreen.addCommand(exit);
/*
* register the MIDlet itself as a event listener
* of the mainScreen.
*/
mainScreen.setCommandListener(this);
}
// implement the startApp() method
public void startApp() {
display.setCurrent(mainScreen);
}
// implemente the pauseApp() method
public void pauseApp() {
}
// implement the destroyApp() method
public void destroyApp(boolean unconditional) {
}
/*
* implement the event handling method defined in
* the CommandListener interface.
*/
public void commandAction(Command c, Displayable s) {
// if the EXIT menu is clicked, exit the program
if(c == exit) {
destroyApp(false);
notifyDestroyed();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?