云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 用Java实现日历记事本

用Java实现日历记事本

  • 62 次阅读
  • 3 次下载
  • 2025/12/12 3:57:28

public void setMonth(int month) { this.month=month; } public int getMonth() { return month; } public void setDay(int day) { this.day=day; } public int getDay() { return day; } public void setNews(int year,int month,int day) { News.setText(\年\月\日\ } public void setText(String s) { text.setText(s); } public void actionPerformed(ActionEvent e) {} public void Save(File file,int year,int month,int day) { //保存日志按钮事件实现 String LogCenter=text.getText(); 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) { try { FileInputStream inOne=new FileInputStream(file); ObjectInputStream inTwo=new ObjectInputStream(inOne); 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){} String f=\日志已更新\ JOptionPane.showMessageDialog(this,f,\提示\ } } else { String m=\年\月\还没有日志,是否保存日志?\//保存还没有的日志 int ok=JOptionPane.showConfirmDialog(this,m,\询问\ JOptionPane.QUESTION_MESSAGE); 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,LogCenter); FileOutputStream out=new FileOutputStream(file); ObjectOutputStream objectOut=new ObjectOutputStream(out); objectOut.writeObject(table); objectOut.close(); out.close(); } catch(Exception ee){} String f=\日志保存成功\ JOptionPane.showMessageDialog(this,f,\提示\ } } } public void Delete(File file,int year,int month,int day) { //删除日志按钮事件实现 String key=\ if(table.containsKey(key)) { String m=\删除\年\月\日的日志吗?\ int yes=JOptionPane.showConfirmDialog(this,m,\询问\ JOptionPane.QUESTION_MESSAGE); if(yes==JOptionPane.YES_OPTION) { try { FileInputStream inOne=new FileInputStream(file); ObjectInputStream inTwo=new ObjectInputStream(inOne); 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){} String f=\日志删除成功\ JOptionPane.showMessageDialog(this,f,\提示\ } } else { String f=\年\月\无记录\ JOptionPane.showMessageDialog(this,f,\提示\ } } public void Read(File file,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,\询问\ if(ok==JOptionPane.YES_OPTION) { text.setText((String)table.get(key)); text.setText(\年\月\日的日志\ } else { text.setText(\ } } else { String f=\年\月\日,暂无记录\ JOptionPane.showMessageDialog(this,f,\提示\ } } } Year类 //Year.java 其源代码为: import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Year extends Box implements ActionListener { int year; JTextField showYear=null; JButton Year1,Year2; CalendarPad CAL; public Year(CalendarPad CAL) {

搜索更多关于: 用Java实现日历记事本 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

public void setMonth(int month) { this.month=month; } public int getMonth() { return month; } public void setDay(int day) { this.day=day; } public int getDay() { return day; } public void setNews(int year,int month,int day) { News.setText(\年\月\日\ } public void setText(String s) { text.setText(s); } public void actionPerformed(ActionEvent

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com