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

📄 commandlistenertest2.java

📁 《精彩的手机UI例程.zip》是很好的手机编辑软件
💻 JAVA
字号:

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class CommandListenerTest2 extends MIDlet {
    private Display display;
    private Command okCommand= new Command("OK",Command.OK,1);
    private Screen1 s1;
    
    public CommandListenerTest2() {
        display=Display.getDisplay(this);
        s1 = new Screen1("Screen 1");
        s1.addCommand(okCommand);
        s1.setCommandListener(s1);
    }
    
    public void startApp() throws MIDletStateChangeException {
        display.setCurrent(s1);
    }

    /**
     * Pause the MIDlet
     */
    public void pauseApp() {
    }

    /**
     * Called by the framework before the application is unloaded
     */
    public void destroyApp(boolean unconditional) {
        s1=null;
	display=null;
    }
    
    class Screen1 extends Form implements CommandListener {
        public Screen1(String title) {
            super(title);
        }
        public void commandAction(Command c,Displayable d) {
            if(c==okCommand) {
                System.out.println("OK is pressed.");
            }
        }
    }
}

⌨️ 快捷键说明

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