电子日历记事本--Java课程设计(5)

2019-06-11 16:26

text.setText(s); } public void 获取日志内容(int year,int month,int day) { String key=\ try { FileInputStream inOne=new FileInputStream(file); ObjectInputStream inTwo=new ObjectInputStream(inOne); table=(Hashtable)inTwo.readObject(); inOne.close(); inTwo.close(); } catch(Exception ee) {} if(table.containsKey(key))

{ String m=\年\月\这一天有日志记载,想看吗?\ int ok=JOptionPane.showConfirmDialog(this,m,\询问\

JOptionPane.QUESTION_MESSAGE); if(ok==JOptionPane.YES_OPTION) {

String str = JOptionPane.showInputDialog(null,\请输入密码\消息对话框\

long num = Integer.parseInt(str); if(num!=123456){ JOptionPane.showInputDialog(this,\密码不正确!\确认对话框\ } else if(num==123456){ int n =JOptionPane.showConfirmDialog(this,\确认正确吗?\确认对话框\ text.setText((String)table.get(key)); } } else

{ text.setText(\ } } else

{ text.setText(\无记录\ }

17

} public void 保存日志(int year,int month,int day) { String 日志内容=text.getText(); String key=\ String m=\年\月\保存日志吗?\ int ok=JOptionPane.showConfirmDialog(this,m,\询问

\ if(ok==JOptionPane.YES_OPTION) { try { FileInputStream inOne=new FileInputStream(file); ObjectInputStream inTwo=new ObjectInputStream(inOne); table=(Hashtable)inTwo.readObject(); inOne.close(); inTwo.close(); table.put(key,日志内容); FileOutputStream out=new FileOutputStream(file); ObjectOutputStream objectOut=new ObjectOutputStream(out); objectOut.writeObject(table); objectOut.close(); out.close(); } catch(Exception ee) {} } } public void 删除日志(int year,int month,int day) { String key=\ if(table.containsKey(key)) { String m=\删除\年\月\日的日志吗?\ int ok=JOptionPane.showConfirmDialog(this,m,\询问

\ if(ok==JOptionPane.YES_OPTION) { try { FileInputStream inOne=new FileInputStream(file); ObjectInputStream inTwo=new ObjectInputStream(inOne);

18

table=(Hashtable)inTwo.readObject(); inOne.close(); inTwo.close(); table.remove(key); FileOutputStream out=new FileOutputStream(file); ObjectOutputStream objectOut=new ObjectOutputStream(out); objectOut.writeObject(table); objectOut.close(); out.close(); text.setText(null); } catch(Exception ee) {} } } else { String m=\年\月\无日志记录\ JOptionPane.showMessageDialog(this,m,\提示\ } } }

19

4系统运行与测试

4.1程序主界面

图1 日历记事本系统主界面

4.2日志查看——无日志

图2 无日志界面

20

4.3建立日志

图3 保存日志

4.4日志查看——有日志

图3有日志

21


电子日历记事本--Java课程设计(5).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2019年高考理科数学仿真冲刺卷及答案(一)

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: