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

📄 showphoto.java

📁 J2ME程序设计实例教程的源码
💻 JAVA
字号:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;

public class ShowPhoto extends MIDlet implements CommandListener {
    Image imgDog = null;
    Image imgDinosaur = null;
    
    //构造方法
    public ShowPhoto() {
        //
    }
      
    public void startApp() {
        Form form = new Form("浏览图片");
        try {
            imgDog = Image.createImage("/Dog.png");
            imgDinosaur = Image.createImage("/Dinosaur.png");
            form.append(imgDog);
            form.append(imgDinosaur);
        }
        catch(IOException ioe){
            form.append(new StringItem("错误!","图片不存在"));
        }
        
        Command cmdExit = new Command("退出", Command.EXIT, 0);
        form.addCommand(cmdExit);
        form.setCommandListener(this);
    
        Display display = Display.getDisplay(this);
        display.setCurrent(form);
    }
      
    public void pauseApp() {
        imgDog = null;
        imgDinosaur = null;
    }
    
    public void destroyApp(boolean undicational) {
        //
    }
    
    //如果用户触发“退出”命令,系统将自动调用这个方法
    public void commandAction(Command cmd, Displayable d) {
        if(cmd.getCommandType() == Command.EXIT){
            notifyDestroyed();
        }
    }
}

⌨️ 快捷键说明

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