?? jsr179example.java
字號:
/* * */package com.sonyericsson.example;import javax.microedition.midlet.*;import javax.microedition.lcdui.*;/** * */public class Jsr179Example extends MIDlet implements CommandListener { private boolean midletPaused = false; //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0| private Command exitCommand; private Command backCommand; private Command backCommand1; private Command stateListener; private Command requestPos; private List list; private Form gpsStatusForm; private TextField GPSStatusTextField; private Form requestTestForm; private TextField requestTextField; //</editor-fold>//GEN-END:|fields|0| //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0| //</editor-fold>//GEN-END:|methods|0| //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize /** * Initilizes the application. * It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method. */ private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize // write pre-initialize user code here//GEN-LINE:|0-initialize|1|0-postInitialize // write post-initialize user code here }//GEN-BEGIN:|0-initialize|2| //</editor-fold>//GEN-END:|0-initialize|2| //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction /** * Performs an action assigned to the Mobile Device - MIDlet Started point. */ public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction // write pre-action user code here switchDisplayable(null, getList());//GEN-LINE:|3-startMIDlet|1|3-postAction // write post-action user code here }//GEN-BEGIN:|3-startMIDlet|2| //</editor-fold>//GEN-END:|3-startMIDlet|2| //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction /** * Performs an action assigned to the Mobile Device - MIDlet Resumed point. */ public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction // write pre-action user code here//GEN-LINE:|4-resumeMIDlet|1|4-postAction // write post-action user code here }//GEN-BEGIN:|4-resumeMIDlet|2| //</editor-fold>//GEN-END:|4-resumeMIDlet|2| //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch /** * Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable. * @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately * @param nextDisplayable the Displayable to be set */ public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch // write pre-switch user code here Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch if (alert == null) { display.setCurrent(nextDisplayable); } else { display.setCurrent(alert, nextDisplayable); }//GEN-END:|5-switchDisplayable|1|5-postSwitch // write post-switch user code here }//GEN-BEGIN:|5-switchDisplayable|2| //</editor-fold>//GEN-END:|5-switchDisplayable|2| //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction /** * Called by a system to indicated that a command has been invoked on a particular displayable. * @param command the Command that was invoked * @param displayable the Displayable where the command was invoked */ public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction // write pre-action user code here if (displayable == gpsStatusForm) {//GEN-BEGIN:|7-commandAction|1|36-preAction if (command == backCommand) {//GEN-END:|7-commandAction|1|36-preAction // write pre-action user code here posRunner.quit(); switchDisplayable(null, getList());//GEN-LINE:|7-commandAction|2|36-postAction // write post-action user code here }//GEN-BEGIN:|7-commandAction|3|23-preAction } else if (displayable == list) { if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|3|23-preAction // write pre-action user code here listAction();//GEN-LINE:|7-commandAction|4|23-postAction // write post-action user code here }//GEN-BEGIN:|7-commandAction|5|38-preAction } else if (displayable == requestTestForm) { if (command == backCommand1) {//GEN-END:|7-commandAction|5|38-preAction // write pre-action user code here switchDisplayable(null, getList());//GEN-LINE:|7-commandAction|6|38-postAction // write post-action user code here } else if (command == requestPos) {//GEN-LINE:|7-commandAction|7|45-preAction // write pre-action user code here uPosRequester.requestPos();//GEN-LINE:|7-commandAction|8|45-postAction // write post-action user code here }//GEN-BEGIN:|7-commandAction|9|7-postCommandAction }//GEN-END:|7-commandAction|9|7-postCommandAction // write post-action user code here }//GEN-BEGIN:|7-commandAction|10| //</editor-fold>//GEN-END:|7-commandAction|10| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand ">//GEN-BEGIN:|18-getter|0|18-preInit /** * Returns an initiliazed instance of exitCommand component. * @return the initialized component instance */ public Command getExitCommand() { if (exitCommand == null) {//GEN-END:|18-getter|0|18-preInit // write pre-init user code here exitCommand = new Command("Exit", Command.EXIT, 0);//GEN-LINE:|18-getter|1|18-postInit // write post-init user code here }//GEN-BEGIN:|18-getter|2| return exitCommand; } //</editor-fold>//GEN-END:|18-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Getter: list ">//GEN-BEGIN:|21-getter|0|21-preInit /** * Returns an initiliazed instance of list component. * @return the initialized component instance */ public List getList() { if (list == null) {//GEN-END:|21-getter|0|21-preInit // write pre-init user code here list = new List("list", Choice.IMPLICIT);//GEN-BEGIN:|21-getter|1|21-postInit list.append("GPS Status", null); list.append("Request Test", null); list.append("Exit", null); list.setCommandListener(this); list.setSelectedFlags(new boolean[] { false, false, false });//GEN-END:|21-getter|1|21-postInit // write post-init user code here }//GEN-BEGIN:|21-getter|2| return list; } //</editor-fold>//GEN-END:|21-getter|2| //<editor-fold defaultstate="collapsed" desc=" Generated Method: listAction ">//GEN-BEGIN:|21-action|0|21-preAction /** * Performs an action assigned to the selected list element in the list component. */ public void listAction() {//GEN-END:|21-action|0|21-preAction // enter pre-action user code here String __selectedString = getList().getString(getList().getSelectedIndex());//GEN-BEGIN:|21-action|1|25-preAction if (__selectedString != null) { if (__selectedString.equals("GPS Status")) {//GEN-END:|21-action|1|25-preAction // write pre-action user code here switchDisplayable(null, getGpsStatusForm());//GEN-LINE:|21-action|2|25-postAction // write post-action user code here posRunner = new PositioningRunner(getGPSStatusTextField()); posRunner.init(); new Thread(posRunner).start(); } else if (__selectedString.equals("Request Test")) {//GEN-LINE:|21-action|3|26-preAction // write pre-action user code here switchDisplayable(null, getRequestTestForm());//GEN-LINE:|21-action|4|26-postAction // write post-action user code here uPosRequester = new UserPosRequester(getRequestTextField()); uPosRequester.init(); } else if (__selectedString.equals("Exit")) {//GEN-LINE:|21-action|5|27-preAction // write pre-action user code here exitMIDlet();//GEN-LINE:|21-action|6|27-postAction
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -