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

📄 gaugetest.java~5~

📁 J2ME的一个简单例子
💻 JAVA~5~
字号:
package j2me;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class GaugeTest extends MIDlet implements CommandListener{
    private Form  form;
    private List  startmenu;
    private String choices[]={"Interactive Gauge","Non-interactive Gauge"};
    private Command backCommand = new Command("Back", Command.BACK, 1);
    private Command exitCommand = new Command("EXIT", Command.EXIT, 1);
    private Display display;

    public GaugeTest() {
        //create a list as start menu
        startmenu= new List("Chooise a Gauge type",List.IMPLICIT,choices,null);
        startmenu.addCommand(exitCommand);
        startmenu.setCommandListener(this);

        //create a form to manage a gauge
        form= new Form("Gauge Test");
        form.addCommand(backCommand);
        form.setCommandListener(this);

        //retrieve display object
        display=Display.getDisplay(this);
    }

    public void startApp() throws MIDletStateChangeException {
        display.setCurrent(startmenu);
    }

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

    /**
     * Called by the framework before the application is unloaded
     */
    public void destroyApp(boolean unconditional) {
        form=null;
        startmenu=null;
        backCommand = null;
        exitCommand = null;
        display=null;
    }

    public void commandAction(Command c, Displayable d) {
        if(d==startmenu && c==List.SELECT_COMMAND) {
            if(form.size()>0) form.delete(0);
            if(startmenu.getSelectedIndex()==0) {
               form.append(new Gauge("Interactive Gauge",false,10,4));
            }
            else {
               form.append(new Gauge("Non-interactive Gauge",false,10,4));
            }
            display.setCurrent(form);
        }
        else if(c==backCommand) {
            display.setCurrent(startmenu);
        }
        else if(c==exitCommand) {
            destroyApp(true);
            notifyDestroyed();
        }
    }
}

⌨️ 快捷键说明

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