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

📄 datefield.java

📁 有关j2me的很好的例子可以研究一下
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * Utility method to return the cosine of an angle     *     * @param angle The angle to compute the cosine of     * @return int The cosine of the angle     */    static int cos(int angle) {        angle += 360000;        angle %= 360;        if (angle >= 270) {            return TRIG_TABLE[360 - angle];        } else if (angle >= 180) {            return -TRIG_TABLE[angle - 180];        } else if (angle >= 90) {            return -TRIG_TABLE[180 - angle];        } else {            return TRIG_TABLE[angle];        }    }    /**     * Utility method to return the sin of an angle     *     * @param angle The angle to compute the sin of     * @return int The sin of the angle     */    static int sin(int angle) {        return cos(angle - 90);    }    // private    /**     * A utility method to do all the necessary height calculations     * when content was changed.     */    private void contentChanged() {        int deltaHeight = ((StringLayout)layouts[1]).setString(                                  toString(mode == TIME ? TIME : DATE));        if (mode == DATE_TIME) {            deltaHeight += ((StringLayout)layouts[2]).setString(                                  mode == DATE_TIME ? toString(TIME) : null);        }        height += deltaHeight;        contentChanged(0, 0, deltaHeight);    }    /**     * A utility method to return a numerical digit as two digits     * if it is less than 10     *     * @param n The number to convert     * @return String The String representing the number in two digits     */    private static String twoDigits(int n) {        if (n == 0) {            return "00";        } else if (n < 10) {            return "0" + n;        } else {            return "" + n;        }    }    /**     * The highlight of this DateField     */    private int highlight;    /**     * A flag indicating the initialization state of this DateField     */    private boolean initialized; // = false;    /**     * The mode of this DateField     */    private int mode;    /**     * The editor for this DateField     */    private EditScreen editor = null;    /**     * The height of this DateField     */    private int height;         //  = 0;    /**     * The last saved date.     * This is used for making the last saved date bold.     */    private Calendar currentDate;    /**     * The image representing an up arrow     */    private static final Image ARROW_UP;    /**     * The image representing an down arrow     */    private static final Image ARROW_DOWN;    /**     * The image representing an left arrow     */    private static final Image ARROW_LEFT;    /**     * The image representing an right arrow     */    private static final Image ARROW_RIGHT;    static {        /**         * The byte array to use for the up arrow         */        byte up_bytes[] = {            (byte)0x89, (byte)0x50, (byte)0x4e, (byte)0x47,            (byte)0x0d, (byte)0x0a, (byte)0x1a, (byte)0x0a,            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x0d,            (byte)0x49, (byte)0x48, (byte)0x44, (byte)0x52,            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x07,            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x04,            (byte)0x08, (byte)0x02, (byte)0x00, (byte)0x00,            (byte)0x00, (byte)0xcd, (byte)0xa4, (byte)0xb2,            (byte)0x2a, (byte)0x00, (byte)0x00, (byte)0x00,            (byte)0x04, (byte)0x67, (byte)0x41, (byte)0x4d,            (byte)0x41, (byte)0x00, (byte)0x00, (byte)0x58,            (byte)0xc7, (byte)0xfc, (byte)0x47, (byte)0xe0,            (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x00,            (byte)0x20, (byte)0x63, (byte)0x48, (byte)0x52,            (byte)0x4d, (byte)0x00, (byte)0x00, (byte)0x7a,            (byte)0x25, (byte)0x00, (byte)0x00, (byte)0x80,            (byte)0x83, (byte)0x00, (byte)0x00, (byte)0xf9,            (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x80,            (byte)0xe8, (byte)0x00, (byte)0x00, (byte)0x75,            (byte)0x30, (byte)0x00, (byte)0x00, (byte)0xea,            (byte)0x60, (byte)0x00, (byte)0x00, (byte)0x3a,            (byte)0x97, (byte)0x00, (byte)0x00, (byte)0x17,            (byte)0x6f, (byte)0x97, (byte)0xa9, (byte)0x99,            (byte)0xd4, (byte)0x00, (byte)0x00, (byte)0x00,            (byte)0x28, (byte)0x49, (byte)0x44, (byte)0x41,            (byte)0x54, (byte)0x78, (byte)0x9c, (byte)0x62,            (byte)0xf8, (byte)0x0f, (byte)0x03, (byte)0x0c,            (byte)0x0c, (byte)0x0c, (byte)0x70, (byte)0x36,            (byte)0x40, (byte)0x00, (byte)0x31, (byte)0xc0,            (byte)0x85, (byte)0x20, (byte)0x00, (byte)0xc2,            (byte)0x05, (byte)0x08, (byte)0x20, (byte)0x06,            (byte)0x64, (byte)0x21, (byte)0xb8, (byte)0x04,            (byte)0x40, (byte)0x00, (byte)0x31, (byte)0x60,            (byte)0x05, (byte)0x00, (byte)0x01, (byte)0x06,            (byte)0x00, (byte)0xbc, (byte)0x0c, (byte)0x23,            (byte)0xdd, (byte)0x02, (byte)0x54, (byte)0x80,            (byte)0xac, (byte)0x00, (byte)0x00, (byte)0x00,            (byte)0x00, (byte)0x49, (byte)0x45, (byte)0x4e,            (byte)0x44, (byte)0xae, (byte)0x42, (byte)0x60,            (byte)0x82,        };        /**         * The byte array to use for the down arrow         */        byte down_bytes[] = {            (byte)0x89, (byte)0x50, (byte)0x4e, (byte)0x47,            (byte)0x0d, (byte)0x0a, (byte)0x1a, (byte)0x0a,            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x0d,            (byte)0x49, (byte)0x48, (byte)0x44, (byte)0x52,            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x07,            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x04,            (byte)0x08, (byte)0x02, (byte)0x00, (byte)0x00,            (byte)0x00, (byte)0xcd, (byte)0xa4, (byte)0xb2,            (byte)0x2a, (byte)0x00, (byte)0x00, (byte)0x00,            (byte)0x04, (byte)0x67, (byte)0x41, (byte)0x4d,            (byte)0x41, (byte)0x00, (byte)0x00, (byte)0x58,            (byte)0xc7, (byte)0xfc, (byte)0x47, (byte)0xe0,            (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x00,            (byte)0x20, (byte)0x63, (byte)0x48, (byte)0x52,            (byte)0x4d, (byte)0x00, (byte)0x00, (byte)0x7a,            (byte)0x25, (byte)0x00, (byte)0x00, (byte)0x80,            (byte)0x83, (byte)0x00, (byte)0x00, (byte)0xf9,            (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x80,            (byte)0xe8, (byte)0x00, (byte)0x00, (byte)0x75,            (byte)0x30, (byte)0x00, (byte)0x00, (byte)0xea,            (byte)0x60, (byte)0x00, (byte)0x00, (byte)0x3a,            (byte)0x97, (byte)0x00, (byte)0x00, (byte)0x17,            (byte)0x6f, (byte)0x97, (byte)0xa9, (byte)0x99,            (byte)0xd4, (byte)0x00, (byte)0x00, (byte)0x00,            (byte)0x26, (byte)0x49, (byte)0x44, (byte)0x41,            (byte)0x54, (byte)0x78, (byte)0x9c, (byte)0x62,            (byte)0x60, (byte)0xc0, (byte)0x06, (byte)0x00,            (byte)0x02, (byte)0x88, (byte)0xe1, (byte)0xff,            (byte)0xff, (byte)0xff, (byte)0x98, (byte)0x22,            (byte)0x00, (byte)0x01, (byte)0x04, (byte)0xc2,            (byte)0xc8, (byte)0x12, (byte)0x10, (byte)0x2e,            (byte)0x40, (byte)0x00, (byte)0x41, (byte)0x29,            (byte)0x88, (byte)0x04, (byte)0x9c, (byte)0x0d,            (byte)0x10, (byte)0x60, (byte)0x00, (byte)0x98,            (byte)0xe9, (byte)0x23, (byte)0xdd, (byte)0x30,            (byte)0xaf, (byte)0x47, (byte)0x9e, (byte)0x00,            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x49,            (byte)0x45, (byte)0x4e, (byte)0x44, (byte)0xae,            (byte)0x42, (byte)0x60, (byte)0x82,        };        /**         * The byte array to use for the left arrow         */        byte left_bytes[] = {            (byte)0x89, (byte)0x50, (byte)0x4e, (byte)0x47,            (byte)0x0d, (byte)0x0a, (byte)0x1a, (byte)0x0a,            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x0d,            (byte)0x49, (byte)0x48, (byte)0x44, (byte)0x52,            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x04,            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x07,            (byte)0x08, (byte)0x02, (byte)0x00, (byte)0x00,            (byte)0x00, (byte)0xa0, (byte)0x07, (byte)0x7b,            (byte)0x87, (byte)0x00, (byte)0x00, (byte)0x00,            (byte)0x04, (byte)0x67, (byte)0x41, (byte)0x4d,            (byte)0x41, (byte)0x00, (byte)0x00, (byte)0x58,            (byte)0xc7, (byte)0xfc, (byte)0x47, (byte)0xe0,            (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x00,            (byte)0x20, (byte)0x63, (byte)0x48, (byte)0x52,            (byte)0x4d, (byte)0x00, (byte)0x00, (byte)0x7a,            (byte)0x25, (byte)0x00, (byte)0x00, (byte)0x80,            (byte)0x83, (byte)0x00, (byte)0x00, (byte)0xf9,            (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x80,            (byte)0xe8, (byte)0x00, (byte)0x00, (byte)0x75,            (byte)0x30, (byte)0x00, (byte)0x00, (byte)0xea,            (byte)0x60, (byte)0x00, (byte)0x00, (byte)0x3a,            (byte)0x97, (byte)0x00, (byte)0x00, (byte)0x17,            (byte)0x6f, (byte)0x97, (byte)0xa9, (byte)0x99,            (byte)0xd4, (byte)0x00, (byte)0x00, (byte)0x00,            (byte)0x32, (byte)0x49, (byte)0x44, (byte)0x41,            (byte)0x54, (byte)0x78, (byte)0x9c, (byte)0x62,            (byte)0xf8, (byte)0x0f, (byte)0x03, (byte)0x0c,            (byte)0x0c, (byte)0x0c, (byte)0x00, (byte)0x01,            (byte)0xc4, (byte)0x80, (byte)0x60, (byte)0x31,            (byte)0x30, (byte)0x00, (byte)0x04, (byte)0x10,            (byte)0x03, (byte)0x82, (byte)0xc5, (byte)0xc0,            (byte)0x00, (byte)0x10, (byte)0x40, (byte)0x28,            (byte)0x08, (byte)0x20, (byte)0x80, (byte)0x50,            (byte)0x64, (byte)0x00, (byte)0x02, (byte)0x08,            (byte)0x45, (byte)0x0f, (byte)0x40, (byte)0x00,            (byte)0x31, (byte)0x20, (byte)0x9b, (byte)0x06,            (byte)0x10, (byte)0x60, (byte)0x00, (byte)0xb9,            (byte)0xf5, (byte)0x23, (byte)0xdd, (byte)0xb2,            (byte)0x55, (byte)0x3d, (byte)0xf7, (byte)0x00,            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x49,            (byte)0x45, (byte)0x4e, (byte)0x44, (byte)0xae,            (byte)0x42, (byte)0x60, (byte)0x82,        };        /**         * The byte array to use for the right arrow         */        byte right_bytes[] = {            (byte)0x89, (byte)0x50, (byte)0x4e, (byte)0x47,            (byte)0x0d, (byte)0x0a, (byte)0x1a, (byte)0x0a,            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x0d,            (byte)0x49, (byte)0x48, (byte)0x44, (byte)0x52,            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x04,            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x07,            (byte)0x08, (byte)0x02, (byte)0x00, (byte)0x00,            (byte)0x00, (byte)0xa0, (byte)0x07, (byte)0x7b,            (byte)0x87, (byte)0x00, (byte)0x00, (byte)0x00,            (byte)0x04, (byte)0x67, (byte)0x41, (byte)0x4d,            (byte)0x41, (byte)0x00, (byte)0x00, (byte)0x58,            (byte)0xc7, (byte)0xfc, (byte)0x47, (byte)0xe0,            (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x00,            (byte)0x20, (byte)0x63, (byte)0x48, (byte)0x52,            (byte)0x4d, (byte)0x00, (byte)0x00, (byte)0x7a,            (byte)0x25, (byte)0x00, (byte)0x00, (byte)0x80,            (byte)0x83, (byte)0x00, (byte)0x00, (byte)0xf9,            (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x80,            (byte)0xe8, (byte)0x00, (byte)0x00, (byte)0x75,            (byte)0x30, (byte)0x00, (byte)0x00, (byte)0xea,            (byte)0x60, (byte)0x00, (byte)0x00, (byte)0x3a,            (byte)0x97, (byte)0x00, (byte)0x00, (byte)0x17,            (byte)0x6f, (byte)0x97, (byte)0xa9, (byte)0x99,            (byte)0xd4, (byte)0x00, (byte)0x00, (byte)0x00,            (byte)0x32, (byte)0x49, (byte)0x44, (byte)0x41,            (byte)0x54, (byte)0x78, (byte)0x9c, (byte)0x62,            (byte)0x60, (byte)0x60, (byte)0x60, (byte)0xf8,            (byte)0x0f, (byte)0x03, (byte)0x00, (byte)0x01,            (byte)0xc4, (byte)0x00, (byte)0x01, (byte)0x10,            (byte)0x0e, (byte)0x40, (byte)0x00, (byte)0x31,            (byte)0xc0, (byte)0x01, (byte)0x90, (byte)0x03,            (byte)0x10, (byte)0x40, (byte)0x0c, (byte)0xc8,            (byte)0x00, (byte)0x20, (byte)0x80, (byte)0x50,            (byte)0x64, (byte)0x00, (byte)0x02, (byte)0x08,            (byte)0x45, (byte)0x0f, (byte)0x40, (byte)0x00,            (byte)0x21, (byte)0x58, (byte)0x40, (byte)0x00,            (byte)0x10, (byte)0x60, (byte)0x00, (byte)0x06,            (byte)0xa9, (byte)0x23, (byte)0xdd, (byte)0xcf,            (byte)0x35, (byte)0x80, (byte)0x1e, (byte)0x00,            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x49,            (byte)0x45, (byte)0x4e, (byte)0x44, (byte)0xae,            (byte)0x42, (byte)0x60, (byte)0x82,        };        ARROW_UP    = Image.createImage(up_bytes, 0, up_bytes.length);        ARROW_DOWN  = Image.createImage(down_bytes, 0, down_bytes.length);        ARROW_LEFT  = Image.createImage(left_bytes, 0, left_bytes.length);        ARROW_RIGHT = Image.createImage(right_bytes, 0, right_bytes.length);    }    /**     * The EditScreen class is a special editor for a DateField.     * It can edit both date and time.     */    class EditScreen extends Screen implements CommandListener {        /**         * Flag to signal whether a select action transfers focus or not         * (false by default)         */        private static final boolean SELECT_TRANSFERS_FOCUS = false;        /**         * Special command to go "back" from the editor to the DateField         */        Command Back = new Command(            Resource.getString("Back"), Command.BACK, 0);        /**         * Special command to "ok" the changes done in the editor         */        Command OK   = new Command            (Resource.getString("Save"), Command.OK, 1);        /**         * Flag to format am/pm string         */        private boolean ampmAfterTime = Resource.isAMPMafterTime();        /**         * The width and height of the editor         */        private int width, height;        /**         * Create a new EditScreen         *         * @param returnScreen The Screen to return to from the editor         * @param field The DateField this EditScreen is editing         */        EditScreen(Screen returnScreen, DateField field) {            super(field.getLabel());            this.returnScreen = returnScreen;            this.field = field;            this.calendar = Calendar.getInstance();            addCommand(OK);            addCommand(Back);            setCommandListener(this);        }        /**         * Handle a command action         *         * @param cmd The Command to handle         * @param s   The Displayable with the Command         */        public void commandAction(Command cmd, Displayable s) {            Form form = null;            Item item = null;

⌨️ 快捷键说明

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