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

📄 locationtimezone.java

📁 这是一个手机上的J2ME程序
💻 JAVA
字号:
// J2ME Compass
// Copyright (C) 2007 Dana Peters
// http://www.qcontinuum.org/compass

package org.qcontinuum.compass;

import java.util.*;
import javax.microedition.lcdui.*;

public class LocationTimeZone extends Form implements CommandListener {

    private boolean mDestination;
    private Location mLocation;
    private Displayable mParent;
    private ChoiceGroup mTimeZoneChoiceGroup, mDstEnabledChoiceGroup;
    private Command mCancelCommand, mOkCommand;
    private String[] mDaylightChoices = {"Automatic", "Disabled"};
    private Vector mTimeZones;

    public LocationTimeZone(Location location, boolean destination, Displayable parent) {
        super("Time Zone");
        mLocation = location;
        mDestination = destination;
        mParent = parent;
        append(mTimeZoneChoiceGroup = new ChoiceGroup("Time Zone", Choice.EXCLUSIVE));
        mTimeZoneChoiceGroup.append("Unknown", null);
        mTimeZones = TimeZone.getZones(this, -12 * mLocation.LongMinutes / 180);
        int selectedIndex = -1;
        int index = 1;
        for (Enumeration e = mTimeZones.elements(); e.hasMoreElements() ;) {
            TimeZone timeZone = (TimeZone)e.nextElement();
            mTimeZoneChoiceGroup.append(timeZone.getName(), null);
            if (mLocation.timeZone != null && mLocation.timeZone.getName().equals(timeZone.getName()))
                selectedIndex = index;
            index++;
        }
        if (selectedIndex > -1)
            mTimeZoneChoiceGroup.setSelectedIndex(selectedIndex, true);
        append(mDstEnabledChoiceGroup = new ChoiceGroup("Daylight Saving", Choice.EXCLUSIVE, mDaylightChoices, null));
        mDstEnabledChoiceGroup.setSelectedIndex(mLocation.dstEnabled ? 0 : 1, 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) {
            int selectedIndex = mTimeZoneChoiceGroup.getSelectedIndex();
            if (selectedIndex == 0) {
                if (!mDestination) {
                    Compass.display("Please select the time zone for this location. "
                            + "Use the same selection as Microsoft Windows \"Date and Time\" control panel.", this);
                    return;
                }
                mLocation.timeZone = null;
                mLocation.dstEnabled = true;
            } else {
                mLocation.timeZone = (TimeZone)mTimeZones.elementAt(selectedIndex - 1);
                mLocation.dstEnabled = mDstEnabledChoiceGroup.getSelectedIndex() == 0;
            }
            Preferences preferences = Compass.getPreferences();
            if (mDestination)
                preferences.setDestination(mLocation);
            else
                preferences.setLocation(mLocation);
            preferences.save();
            Compass.setRefresh(true);
            Compass.display("Please enter a name to save this location.", 5, new LocationSaveName(mLocation, mParent));
        } else if (c == mCancelCommand) {
            Compass.display(mParent);
        }
    }

}

⌨️ 快捷键说明

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