locationairportcode.java

来自「这是一个手机上的J2ME程序」· Java 代码 · 共 43 行

JAVA
43
字号
// J2ME Compass
// Copyright (C) 2007 Dana Peters
// http://www.qcontinuum.org/compass

package org.qcontinuum.compass;

import javax.microedition.lcdui.*;

public class LocationAirportCode extends TextBox implements CommandListener {

    private Location mLocation;
    private Displayable mParent;
    private Command mOkCommand, mCancelCommand;

    public LocationAirportCode(Location location, Displayable parent) {
        super("Search Airport", "", 4, TextField.ANY);
        mLocation = location;
        mParent = parent;
        addCommand(mOkCommand = new Command("OK", Command.OK, 0));
        addCommand(mCancelCommand = new Command("Cancel", Command.CANCEL, 0));
        setCommandListener(this);
    }
    public void commandAction(Command c, Displayable d)  {
        if (c == mOkCommand) {
            String airportCode = getString().toUpperCase();
            if (airportCode.length() == 3 || airportCode.length() == 4) {
                Compass.display(new LocationAirportSearch(mParent, mLocation, airportCode));
            } else {
                Alert alert = new Alert("Airport Code");
                alert.setTimeout(Alert.FOREVER);
                alert.setType(AlertType.ERROR);
                alert.setString("Please enter the 3 or 4 letter code for the nearest airport. "
                        + "For example, enter LHR for London Heathrow. "
                        + "This code normally appears on luggage tags.");
                Compass.display(alert, this);
            }
        } else if (c == mCancelCommand) {
           Compass.display(mParent);
        }
    }

}

⌨️ 快捷键说明

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