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

📄 viewnote.java

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

package net.bccn.account.ui;

import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
import net.bccn.account.model.Note;
import net.bccn.account.util.Util;

/**
 *
 * @author hadeslee
 */
public class ViewNote extends List implements CommandListener{
    private static ViewNote me;
    private Command view,modify,delete,back;
    private Note[] notes;
    /** Creates a new instance of ViewNote */
    private ViewNote() {
        super("查看笔记",Choice.EXCLUSIVE);
        initWindow();
    }
    private void initWindow(){
        this.setFitPolicy(Choice.TEXT_WRAP_OFF);
        view=new Command("查看",Command.OK,1);
        modify=new Command("修改",Command.SCREEN,2);
        delete=new Command("删除",Command.SCREEN,3);
        back=new Command("返回",Command.BACK,0);
        this.addCommand(view);
        this.addCommand(modify);
        this.addCommand(delete);
        this.addCommand(back);
        this.setCommandListener(this);
    }
    public static ViewNote getInstance(){
        if(me==null){
            me=new ViewNote();
        }
        return me;
    }
    public static void showViewNote(Note[] notes){
        if(me==null){
            me=new ViewNote();
        }
        me.notes=notes;
        me.deleteAll();
        for(int i=0;i<notes.length;i++){
            me.append(notes[i].toString(),null);
        }
    }
    public static void updateList(Note note){
        for(int i=0;i<me.notes.length;i++){
            if(note.getID()==me.notes[i].getID()){
                me.notes[i]=note;
                me.set(i,note.toString(),null);
            }
        }
    }
    public void commandAction(Command command, Displayable displayable) {
        if(command==back){
            Util.changeTo(Util.VIEW_NOTE_FORM);
        }else if(command==view){
            int index=this.getSelectedIndex();
            Util.moveTo(AddNote.getInstance(notes[index],false));
        }else if(command==modify){
            int index=this.getSelectedIndex();
            Util.moveTo(AddNote.getInstance(notes[index],true));
        }else if(command==delete){
            int index=this.getSelectedIndex();
            boolean b=Util.deleteRecord(notes[index]);
            if(b){
                Util.showINFO(AlertType.INFO,"笔记删除成功!!");
                
                Note[] newNs=new Note[notes.length-1];
                boolean add=false;
                //如果找到了删除的那个下标,那么后面的元素就要加一了
                for(int i=0;i<newNs.length;i++){
                    if(i==index){
                        add=true;
                    }
                    if(add){
                        newNs[i]=notes[i+1];
                    }else{
                        newNs[i]=notes[i];
                    }
                }
                 notes=newNs;
                this.delete(index);
            }else{
                Util.showINFO(AlertType.ERROR,"笔记删除失败!!");
            }
        }
    }
}

⌨️ 快捷键说明

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