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

📄 helloworld.java

📁 j2me
💻 JAVA
字号:
// 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -