optionsunits.java

来自「GPS Track connects to a GPS and records 」· Java 代码 · 共 38 行

JAVA
38
字号
// J2ME GPS Track
// Copyright (C) 2006 Dana Peters
// http://www.qcontinuum.org/gpstrack

package org.qcontinuum.gpstrack;

import javax.microedition.lcdui.*;

public class OptionsUnits extends List implements CommandListener {
    
    private Displayable mParent;
    private Command mOkCommand, mCancelCommand;
    
    public OptionsUnits(Displayable parent) {
        super("Units", List.EXCLUSIVE);
        mParent = parent;
        append("Metric", null);
        append("U.S.", null);
        Preferences preferences = GpsTrack.getPreferences();
        int units = preferences.getUnitType();
        setSelectedIndex(units, true);
        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) {
            Preferences preferences = GpsTrack.getPreferences();
            preferences.setUnitType(getSelectedIndex());
            preferences.save();
            GpsTrack.display(mParent);
        } else if (c == mCancelCommand) {
            GpsTrack.display(mParent);
        }
    }
}

⌨️ 快捷键说明

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