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

📄 addnote.java

📁 J2ME编的手机助手 文件下载解压缩以后,是一个NetBeans的工程文件,如果有NB的朋友,可以直接打开编辑 源文件在src目录下面,可执行文件在dist目录下 功能如下 1
💻 JAVA
字号:
/*
 * AddNote.java
 *
 * Created on 2007年3月15日, 上午10:10
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package net.bccn.account.ui;

import java.util.Date;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import net.bccn.account.model.Note;
import net.bccn.account.util.Util;

/**
 *
 * @author hadeslee
 */
public class AddNote extends TextBox implements CommandListener {
    private static AddNote me;
    private Command ok,back,reset;
    private boolean isModify;//是否可修改
    private Note temp;//一个暂时变量
    /** Creates a new instance of AddNote */
    public AddNote() {
        super("请输入内容:(最多1000字)",null,1000,TextField.ANY);
        initWindow();
    }
    private void initWindow(){
        ok=new Command("确定",Command.OK,1);
        back=new Command("返回",Command.BACK,0);
        reset=new Command("重置",Command.SCREEN,2);
        this.addCommand(ok);
        this.addCommand(back);
        this.addCommand(reset);
        this.setCommandListener(this);
    }
    public static AddNote getInstance(){
        if(me==null){
            me=new AddNote();
        }
        me.reset();
        return me;
    }
    public static AddNote getInstance(Note note,boolean isModify){
        if(me==null){
            me=new AddNote();
        }
        me.temp=note;
        me.isModify=isModify;
        if(isModify){
            me.setTitle("修改笔记");
            me.addCommand(me.ok);
            me.addCommand(me.back);
            me.removeCommand(me.reset);
        }else{
            me.removeCommand(me.ok);
            me.removeCommand(me.reset);
            me.setTitle("查看笔记");
        }
        me.setString(note.getContent());
        return me;
    }
    private Note getNote(){
        Note n=new Note();
        n.setContent(this.getString());
        n.setDate(new Date());
        if(isModify){
            n.setID(temp.getID());
        }
        return n;
    }
    public void commandAction(Command command, Displayable displayable) {
        if(command==ok){
            String s=this.getString();
            if(s==null||s.equals("")){
                Util.showINFO(AlertType.ERROR,"内容不能为空!!");
            }else{
                if(isModify){
                    temp.setContent(s);
                    boolean b=Util.updateRecord(temp);
                    if(b){
                        Util.showINFO(AlertType.INFO,"修改笔记成功!请返回",ViewNote.getInstance());
                        this.setString(null);
                        ViewNote.updateList(temp);
                    }else{
                        Util.showINFO(AlertType.ERROR,"修改笔记失败!");
                    }
                }else{
                    boolean b=Util.saveRecord(getNote());
                    if(b){
                        Util.showINFO(AlertType.INFO,"保存笔记成功!");
                        this.setString(null);
                    }else{
                        Util.showINFO(AlertType.ERROR,"保存笔记失败!");
                    }
                }
            }
            
        }else if(command==back){
            if(temp!=null){
                temp=null;
                this.setString(null);
                Util.changeTo(Util.VIEW_NOTE);
            }else{
                Util.changeTo(Util.MAIN_FORM);
            }
        }else if(command==reset){
            reset();
            this.setString(null);
        }
    }
    private void reset(){
        isModify=false;
        temp=null;
        this.setTitle("请输入内容:(最多1000字)");
        this.addCommand(ok);
        this.addCommand(back);
        this.addCommand(reset);
    }
    
}

⌨️ 快捷键说明

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