locationsavename.java

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

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

package org.qcontinuum.compass;

import javax.microedition.lcdui.*;
import javax.microedition.rms.*;

public class LocationSaveName extends TextBox implements CommandListener {

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

    public LocationSaveName(Location location, Displayable parent) {
        super("Location Name", "", 15, TextField.ANY);
        mLocation = location;
        mParent = parent;
        if (mLocation.Name != null && mLocation.Name.length() > 0) {
            setString(mLocation.Name);
        }
        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 == mCancelCommand) {
           Compass.display(mParent);
        } else if (c == mOkCommand) {
            String locationName = getString().trim();
            if (locationName.length() > 0) {
                mLocation.Name = locationName;
                mLocation.save();
                Compass.display(mParent);
            }
        }
    }

}

⌨️ 快捷键说明

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