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

📄 simplemidlet.java

📁 j2me简单实例,j2me教程加源码,希望大家喜欢
💻 JAVA
字号:
package com.j2medev.chapter2;

import javax.microedition.lcdui.*; 
import javax.microedition.midlet.MIDlet; 
import java.io.*;
 
public class SimpleMIDlet extends MIDlet implements CommandListener {
  private Display display = null; 
  private Command exitCommand = new Command("Exit", Command.EXIT, 0); 
  public void startApp() { 
    //获得Display实例
    display = Display.getDisplay(this); 
    Form mainForm = new Form("simple"); 
    Image img = null;
    //创建Image对象
    try{
      img = Image.createImage("/JavaPowered.png");
    }catch(IOException ex){
      ex.printStackTrace();
    }
    if(img != null) 
      mainForm.append(img); 
    //添加Command并注册监听器
    mainForm.addCommand(exitCommand); 
    mainForm.setCommandListener(this); 
    display.setCurrent(mainForm); 
  } 
   
  public void pauseApp () {} 
   
  public void destroyApp(boolean unconditional) {} 
   //Command事件处理,响应用户按键
  public void commandAction(Command cmd, Displayable s) { 
if (cmd==exitCommand) {
  destroyApp(false);
      notifyDestroyed();
	} 
  } 
}

⌨️ 快捷键说明

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