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

📄 时间工具.txt

📁 每年到这个时候会有很多毕业生 为了毕业设计而发愁
💻 TXT
字号:
/*作者:向宗尧  QQ:112458587
 *  个人作品,多多支持!
 */

package com.j2medev.timetools;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.*;
import javax.microedition.io.PushRegistry;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;

    
 
public class TimeTools extends MIDlet implements ItemCommandListener, CommandListener {    
    private Display display = null;
    private Form mainForm = new Form("时间工具");
    //Ticker对象
    Ticker ticker = new Ticker("作者:向宗尧    QQ:112458587");
    static final Command AddTickerCommand = new Command("",Command.ITEM,1);
    private StringItem stopwatch_stringItem,countdown_stringItem,schedule_stringItem,
            alarmclock_stringItem,timepice_stringItem,timetable_stringItem,
            globetime_stringItem,instruction_stringItem,calendar_stringItem;
    private Command cmdExit = new Command("退出",Command.EXIT,1);
    private Command cmdStopWatch = new Command("选择",Command.ITEM,1);
    private Command cmdCountDown = new Command("选择",Command.ITEM,1);
    private Command cmdSchedule = new Command("选择",Command.ITEM,1);
    private Command cmdCalendar = new Command("选择",Command.ITEM,1);
    private Command cmdAlarmClock= new Command("选择",Command.ITEM,1);
    private Command cmdTimePice = new Command("选择",Command.ITEM,1);
    private Command cmdTimeTable = new Command("选择",Command.ITEM,1);
    private Command cmdGlobeTime = new Command("选择",Command.ITEM,1);
    private Command cmdInstruction = new Command("选择",Command.ITEM,1); 
    private Command cmdBack = new Command("返回",Command.BACK,2);
    private DateField mDateField;
    
            
    
    public TimeTools() {
        if(display==null) {
            display = Display.getDisplay(this);
            alarmclock_stringItem = new StringItem("闹钟", null, StringItem.PLAIN);
            timepice_stringItem = new StringItem("时间显示", null, StringItem.PLAIN);
            timetable_stringItem = new StringItem("时钟显示", null, StringItem.PLAIN);
            calendar_stringItem = new StringItem("日历显示", null, StringItem.PLAIN);
            globetime_stringItem = new StringItem("世界时间", null, StringItem.PLAIN);
            stopwatch_stringItem = new StringItem("百事秒表", null, StringItem.PLAIN);
            countdown_stringItem = new StringItem("沙漏倒计时", null, StringItem.PLAIN);
            schedule_stringItem = new StringItem("日程备忘录", null, StringItem.PLAIN);            
            instruction_stringItem = new StringItem("说明", null, StringItem.PLAIN);
            alarmclock_stringItem.setDefaultCommand(cmdAlarmClock);
            timepice_stringItem.setDefaultCommand(cmdTimePice);
            timetable_stringItem.setDefaultCommand(cmdTimeTable);
            calendar_stringItem.setDefaultCommand(cmdCalendar);
            globetime_stringItem.setDefaultCommand(cmdGlobeTime);
            stopwatch_stringItem.setDefaultCommand(cmdStopWatch);
            countdown_stringItem.setDefaultCommand(cmdCountDown);
            schedule_stringItem.setDefaultCommand(cmdSchedule);
            instruction_stringItem.setDefaultCommand(cmdInstruction);
            //注册ItemCommandListener监听器
            alarmclock_stringItem.setItemCommandListener(this);
            timepice_stringItem.setItemCommandListener(this);
            timetable_stringItem.setItemCommandListener(this);
            calendar_stringItem.setItemCommandListener(this);
            globetime_stringItem.setItemCommandListener(this);
            stopwatch_stringItem.setItemCommandListener(this);
            countdown_stringItem.setItemCommandListener(this);
            schedule_stringItem.setItemCommandListener(this);
            instruction_stringItem.setItemCommandListener(this);
            mainForm.append(alarmclock_stringItem);
            mainForm.append(timepice_stringItem);
            mainForm.append(timetable_stringItem);
            mainForm.append(calendar_stringItem);
            mainForm.append(stopwatch_stringItem);
            mainForm.append(globetime_stringItem);
            mainForm.append(countdown_stringItem);
            mainForm.append(schedule_stringItem); 
            mainForm.append(instruction_stringItem);
            mainForm.addCommand(cmdBack);
            mainForm.setCommandListener(this);
        }       
    }

    public void alarmclock() throws Exception {//闹钟  
       mainForm.setTitle("闹钟");
       mainForm.deleteAll();
       //timeTask
   }   
  
    public void timepice() throws Exception { //时间显示
       mainForm.setTitle("时间显示");
       mainForm.deleteAll();
       scheduleMIDlet(10000);
    }
       private void scheduleMIDlet(long delt){
           try{
               Date now = new Date();
               PushRegistry.registerAlarm(this.getClass().getName(),now.getTime()+delt);
           }catch(Exception e){
               e.printStackTrace();
           }
       }
       
    public void timetable() throws Exception {//钟
       mainForm.setTitle("钟表显示");
       mainForm.deleteAll();
   }   
   public void calendar() throws Exception {//日历显示
       mainForm.setTitle("日历显示");
       mainForm.deleteAll();
       mDateField = new DateField("Date",DateField.DATE);
       mainForm.append(mDateField);       
       mainForm.addCommand(cmdExit);
       mainForm.setCommandListener(this);
       Display.getDisplay(this).setCurrent(mainForm);
       ItemStateListener listener = new ItemStateListener(){
           public void itemStateChange(Item item){
               if(item==mDateField){
                   Calendar calendar = Calendar.getInstance(TimeZone.getDefault());
                   calendar.setTime(mDateField.getDate());
               }
           }
            public void itemStateChanged(Item arg0) {
            }
       };
       mainForm.setItemStateListener(listener);
   }       
   public void globetime() throws Exception {//世界时间
       mainForm.setTitle("世界时间");
       mainForm.deleteAll();
   } 
    private void stopwatch() throws Exception {//百事秒表
        mainForm.setTitle("百事秒表");
        mainForm.deleteAll();
        /*long startTime = System.currentTimeMillis();
        long endTime = System.currentTimeMillis() + 2*60*1000;
        long nowTime = System.currentTimeMillis();
        if (nowTime == endTime) {            
        }*/
        
    }   
   public void countdown() throws Exception {//沙漏倒计时
       mainForm.setTitle("沙漏倒计时");
       mainForm.deleteAll();
       String a = "12545";
       TextField b = new TextField("aaa",a,15,TextField.UNEDITABLE);       
       mainForm.append(b);
       Display.getDisplay(this).setCurrent(mainForm);
   }   
   public void schedule() throws Exception {//日程
       mainForm.setTitle("日程管理");
       mainForm.deleteAll();
   }      
   public void instruction() throws Exception {//说明
       mainForm.setTitle("说明");
       mainForm.deleteAll();
       StringItem text = new StringItem("","个人作品,多多支持,你能想到的就是我能做到的,全心全意为你打造专业、人性的服务");

        Font font = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_UNDERLINED, Font.SIZE_LARGE);
       text.setFont(font);
       mainForm.append(text);
       Display.getDisplay(this).setCurrent(mainForm);
   }       
    public void startApp() throws MIDletStateChangeException {   
        mainForm.setTicker(ticker);
        display = Display.getDisplay(this);
        display.setCurrent(mainForm);        
    }    
    public void pauseApp() {
    }    
    public void destroyApp(boolean unconditional) {
    }    
    public void commandAction(Command cmd,Displayable displayable){
        if(cmd == cmdBack){
            destroyApp(false); 
            notifyDestroyed();
        }
    }
    //当特定Item上的Command被按下的时候此方法就会被调用 
    public void commandAction(Command cmd, Item item) {
        if(cmd == cmdStopWatch){
            
            try {
                stopwatch();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }else if(cmd == cmdCountDown){
            if(item == countdown_stringItem){
                try {
                    countdown();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }else if(cmd == cmdSchedule){
            if(item == schedule_stringItem){
                try {
                    schedule();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }else if(cmd == cmdAlarmClock){
            if(item == alarmclock_stringItem){
                try {
                    alarmclock();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }else if(cmd == cmdTimePice){
            if(item == timepice_stringItem){
                try {
                    timepice();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }else if(cmd == cmdTimeTable){
            if(item == timetable_stringItem){
                try {
                    timetable();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }else if(cmd == cmdGlobeTime){
            if(item == globetime_stringItem){
                try {
                    globetime();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }else if(cmd == cmdCalendar){
            if(item == calendar_stringItem){
                try {
                    calendar();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }else if(cmd == cmdInstruction){
            if(item == instruction_stringItem){
                try {     
                    instruction();
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }        
    }    
}

⌨️ 快捷键说明

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