/*
* HelloMidlet.java
* My first J2ME apllication
* Created on 7. September 2007, 09:12
*
* Revised from the example in Core J2ME:
* 1. The data read and write from/to rsOftenUsed (a RecordStore where the often used todo texts are saved)
* is written with a new algorithm -- packing and unpacking the data not with objects anymore.
* But the rsTodo still follows the old way, as described in "Core J2ME".
* ==> Some code are duplicated in this class and in MyRecordStore, just because of the two ways in saving data.
* 2. A choicegroup which contains the often used todos was added, because I find
* the inconvienint of entering words is one of the biggest drawbacks of cell phone
* applications.
* 3. Another dimension priority is added.==> priority{1, 2, 3, 4,5}; date{"Today","Tomorrow","This week", "This month","Someday"}
* 4. The programm was divided into GUI class and backend class.
* MyRecordStore and TodoItem can be easyly reused in other application.
* ThProgram in is way looks more like the J2EE structure (JSP+ JDBC+ base class).
* 5. The DisplayManger is not used here. Because with the NetBeans' visual MIDlet are the screen flows calearly managed.
* 6. The preference form is deleted, because I think most people don't like the todos unsorted
* 7. I didn't use writeVector2RMS(): The data are not written to vector then written to RMS.
* I wrote a addRecord() method, so that data are directly written into RMS, which is more effiecient.
* 8. The todo is listed by a List screen, instead of Choice Group as showed in Core J2ME
*
* My todo for this program:
* Because I'm a Chinese but my cell phone cannot display Chinese. so I'll try to add the Chinese characters into the choicegroup (cgOftenUsed).
* To make it that way, I'll have to save Chinese characters as images.
* Which also means, I'll also have to rewrite MyRecordStore.Because it is no more readUTF(), but the english or german Strings are readUTF().
* ==> It is not just a problem of languages, but also a problem between Images and Strings.
*/
package hello;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Vector;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.rms.InvalidRecordIDException;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;
import javax.microedition.rms.RecordStoreNotOpenException;
/**
*
* @author snowtree
*/
public class HelloMidlet extends MIDlet implements CommandListener {
/** Constructor of the TodoMidlet */
public HelloMidlet() {
try {
rsOftenUsed = RecordStore.openRecordStore("rsOftenUsed", true);
// Initialize the streams
initInputStreams();
initOutputStreams();
} catch (RecordStoreException ex) {
ex.printStackTrace();
}
}
private Vector vecTodo;//todo in each date
private Vector vecDate;
private short nToday=0, nTomorrow=0, nWeek=0, nMonth=0, nSomeday=0;
private MyRecordStore rsTodo=new MyRecordStore("rsTodo");
private RecordStore rsOftenUsed;
//private MyRecordStore rsOftenUsed=new MyRecordStore("rsOftenUsed");
private Form addTodoForm;//GEN-BEGIN:MVDFields
private Command exitCommand;
private List todoListScreen;
private Command exitCommand1;
private Command itemCommand1;
private Command addTodoCommand;
private TextField tfTodo;
private ChoiceGroup cgDate;
private Command saveAddTodoCommand;
private Command cancelCommand1;
private Command addAnotherCommand;
private Command deleteCommand;
private ChoiceGroup cgPriority;
private ImageItem imageItem1;
private ImageItem imageItem2;
private org.netbeans.microedition.lcdui.SplashScreen splashScreen1;
private Image image1;
private Font font1;
private ChoiceGroup choiceGroup1;
private Spacer spacer1;
private Spacer spacer2;
private ChoiceGroup cgOftenUsed;
private Spacer spacer3;
private Command oftenCommand;
private Command cmdOftenfrList;
private Command cmdDeleteOften;
private Command okCommand1;
private Command cmdOftenUsed;
private Command itemCommand5;
private Command cmdSaveFrOften;//GEN-END:MVDFields
//GEN-LINE:MVDMethods
/** This method initializes UI of the application.//GEN-BEGIN:MVDInitBegin
*/
private void initialize() {//GEN-END:MVDInitBegin
// Insert pre-init code here
getDisplay().setCurrent(get_splashScreen1());
}//GEN-LINE:MVDInitEnd
/** Called by the system to indicate that a command has been invoked on a particular displayable.//GEN-BEGIN:MVDCABegin
* @param command the Command that ws invoked
* @param displayable the Displayable on which the command was invoked
*/
public void commandAction(Command command, Displayable displayable) {//GEN-END:MVDCABegin
// Insert global pre-action code here
if (displayable == addTodoForm) {//GEN-BEGIN:MVDCABody
if (command == exitCommand) {//GEN-END:MVDCABody
// Insert pre-action code here
exitMIDlet();//GEN-LINE:MVDCAAction3
// Insert post-action code here
} else if (command == saveAddTodoCommand) {//GEN-LINE:MVDCACase3
// Insert pre-action code here
saveAddTodo();
rebuildTodoList();
getDisplay().setCurrent(get_todoListScreen());//GEN-LINE:MVDCAAction20
// Insert post-action code here
} else if (command == cancelCommand1) {//GEN-LINE:MVDCACase20
// Insert pre-action code here
getDisplay().setCurrent(get_todoListScreen());//GEN-LINE:MVDCAAction22
// Insert post-action code here
} else if (command == addAnotherCommand) {//GEN-LINE:MVDCACase22
// Insert pre-action code here
saveAddTodo();
// Do nothing//GEN-LINE:MVDCAAction24
// Insert post-action code here
} else if (command == cmdDeleteOften) {//GEN-LINE:MVDCACase24
deleteOftenUsed();
rebuildOftenUsedCg();
// Do nothing//GEN-LINE:MVDCAAction80
// Insert post-action code here
} else if (command == cmdOftenUsed) {//GEN-LINE:MVDCACase80
// Insert pre-action code here
saveAsOftenUsedTf();
rebuildOftenUsedCg();
// Do nothing//GEN-LINE:MVDCAAction93
// Insert post-action code here
} else if (command == cmdSaveFrOften) {//GEN-LINE:MVDCACase93
// Insert pre-action code here
saveFromOften();
getDisplay().setCurrent(get_todoListScreen());//GEN-LINE:MVDCAAction97
rebuildTodoList();
}//GEN-BEGIN:MVDCACase97
} else if (displayable == todoListScreen) {
if (command == addTodoCommand) {//GEN-END:MVDCACase97
// Insert pre-action code here
getDisplay().setCurrent(get_addTodoForm());//GEN-LINE:MVDCAAction13
// Insert post-action code here
rebuildOftenUsedCg();
} else if (command == exitCommand1) {//GEN-LINE:MVDCACase13
// Insert pre-action code here
exitMIDlet();//GEN-LINE:MVDCAAction9
// Insert post-action code here
} else if (command == deleteCommand) {//GEN-LINE:MVDCACase9
// Insert pre-action code here
deleteTodoItem();
reb
没有合适的资源?快使用搜索试试~ 我知道了~
手机版小小备忘录(J2ME源码)
共95个文件
class:66个
java:6个
jpg:5个
4星 · 超过85%的资源 需积分: 10 225 下载量 70 浏览量
2007-09-12
21:54:13
上传
评论
收藏 381KB RAR 举报
温馨提示
可以把要做的事存在手机上,按优先顺序和时间显示。<br><br>数据库:rms. 程序中用到两个recordStore。rsTodo用的最常用的方法--把数据读入到objects中,然后存入vector。但是此过程中会多次调用"new",如果记录比较多,特别是频繁读取记录,会大大降低效率。所以第二个recordstore将记录从rms中读出来,不unpack到objects里,直接append到list上,同时用一个数组记录在list上的序列和在rms中的recordID。查询、删除、更新时直接从这个数组中读出recordID然后进行相应操作。<br><br>用Netbeans写的,MIDlet代码用eclipse看可能会有些Netbeans的多余的预置码。
资源推荐
资源详情
资源评论
收起资源包目录
MyTodo1.2.rar (95个子文件)
MyTodo
dist
MyTodo.jar 44KB
MyTodo.jad 231B
src
logo_8734.gif 7KB
hello
MyRecordStore.java 11KB
HelloMidlet.mvd 22KB
TodoItem.java 983B
HelloMidlet.java 39KB
build
preprocessed
logo_8734.gif 7KB
hello
MyRecordStore.java 11KB
TodoItem.java 983B
HelloMidlet.java 39KB
obfuscated.jar 44KB
manifest.mf 173B
preverified
org
netbeans
microedition
lcdui
TableModel.class 434B
SimpleTableModel.class 5KB
AbstractInfoScreen.class 6KB
laf
UserColorSchema.class 2KB
SystemColorSchema.class 2KB
ColorSchema.class 3KB
WaitScreen$BackgroundExecutor.class 2KB
WaitScreen$1.class 675B
TableItem.class 14KB
SplashScreen.class 3KB
TableModelListener.class 227B
WaitScreen$BackgroundExecutor$1.class 1KB
WaitScreen.class 4KB
SplashScreen$1.class 241B
SplashScreen$Watchdog.class 1KB
util
CancellableTask.class 262B
SimpleCancellableTask.class 1KB
Executable.class 204B
hello
TodoItem.class 913B
MyRecordStore.class 6KB
MyRecordStore$ComparatorInt.class 2KB
HelloMidlet.class 17KB
obfuscated
org
netbeans
microedition
lcdui
TableModel.class 434B
SimpleTableModel.class 5KB
AbstractInfoScreen.class 6KB
laf
UserColorSchema.class 2KB
SystemColorSchema.class 2KB
ColorSchema.class 3KB
WaitScreen$BackgroundExecutor.class 2KB
WaitScreen$1.class 675B
TableItem.class 14KB
SplashScreen.class 3KB
TableModelListener.class 227B
WaitScreen$BackgroundExecutor$1.class 1KB
WaitScreen.class 4KB
SplashScreen$1.class 241B
SplashScreen$Watchdog.class 1KB
util
CancellableTask.class 262B
SimpleCancellableTask.class 1KB
Executable.class 204B
META-INF
MANIFEST.MF 106B
logo_8734.gif 7KB
hello
TodoItem.class 913B
MyRecordStore.class 5KB
MyRecordStore$ComparatorInt.class 1KB
HelloMidlet.class 16KB
before-obfuscation.jar 44KB
compiled
org
netbeans
microedition
lcdui
TableModel.class 434B
SimpleTableModel.class 5KB
AbstractInfoScreen.class 6KB
laf
UserColorSchema.class 2KB
SystemColorSchema.class 2KB
ColorSchema.class 3KB
WaitScreen$BackgroundExecutor.class 2KB
WaitScreen$1.class 675B
TableItem.class 14KB
SplashScreen.class 3KB
TableModelListener.class 227B
WaitScreen$BackgroundExecutor$1.class 1KB
WaitScreen.class 4KB
SplashScreen$1.class 241B
SplashScreen$Watchdog.class 1KB
util
CancellableTask.class 262B
SimpleCancellableTask.class 1KB
Executable.class 204B
logo_8734.gif 7KB
hello
TodoItem.class 913B
MyRecordStore.class 5KB
MyRecordStore$ComparatorInt.class 1KB
HelloMidlet.class 16KB
doc
delete1.jpg 21KB
addTodo1.jpg 24KB
Splash.jpg 19KB
Screenflow.jpg 48KB
addTodo.jpg 28KB
build.xml 3KB
nbproject
build-impl.xml 27KB
private
private.xml 211B
private.properties 172B
project.properties 5KB
project.xml 557B
genfiles.properties 455B
共 95 条
- 1
资源评论
- wang_cuntao2013-05-10代码在eclipese下运行有错误
- loghbb2012-12-09太有用了,很实用,对我的学习帮助很大!!!
- choukee2013-07-12可用,代码写的不错。多谢分享!
- betheart2013-02-28太有用了,很实用,对我的学习帮助很大!!! .
混迹天涯
- 粉丝: 3
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- note test a bc d e f g h
- MERGE.csv.zip
- 15白落梅:你是锦瑟我为流年:三毛的万水千山-3491776.mobi
- 微信小程序源码 实现 城市切换 demo 根据城市首字母排序城市 选择城市
- 12因为懂得 所以慈悲-张爱玲的倾城往事 (白落梅经典散文系列)-3321089.mobi
- 基于 C# 实现的串口温度监控软件
- 基于STM32F103RBT6单片机+SIM868自动收货机主控板硬件(原理图+PCB)工程文件.zip
- 微信小程序源码 车源宝 二手车交易平台 源码下载
- 专注于在线教育领域,打造更好的网课系统,网校系统,知识付费系统
- ADM487EARZ-REEL7 产品规格书pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功