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

当前位置:首页 > 用Java实现日历记事本源代码2660【新版】

用Java实现日历记事本源代码2660【新版】

  • 62 次阅读
  • 3 次下载
  • 2025/12/9 7:26:29

保存日志.addActionListener(this); 删除日志.addActionListener(this); setLayout(new BorderLayout()); JPanel pSouth=new JPanel();

add(信息条,BorderLayout.NORTH); pSouth.add(保存日志); pSouth.add(删除日志);

add(pSouth,BorderLayout.SOUTH);

add(new JScrollPane(text),BorderLayout.CENTER); }

public void actionPerformed(ActionEvent e) {

if(e.getSource()==保存日志) {

保存日志(year,month,day); }

else if(e.getSource()==删除日志) {

删除日志(year,month,day); } }

public void setYear(int year) {

this.year=year; }

public int getYear() {

return year; }

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 设置信息条(int year,int month,int day) {

信息条.setText(\年\月\日\ }

public void 设置文本区(String s) {

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,\询\~ 16 / 25 ~

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

text.setText((String)table.get(key)); } else {

text.setText(\ } } else {

text.setText(\无记录\ } }

...

public void 保存日志(int year,int month,int day) {

String 日志内容=text.getText();

String key=\

String m=\年\月\保存日志吗?\

int ok=JOptionPane.showConfirmDialog(this,m,\询问\ JOptionPane.QUESTION_MESSAGE); if(ok==JOptionPane.YES_OPTION) { try ~ 17 / 25 ~

{

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=\删除\年\月\日的日志吗?\~ 18 / 25 ~

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(); ~ 19 / 25 ~

out.close();

text.setText(null); }

catch(Exception ee) { } } } else {

String m=\年\月\无日志记录\ JOptionPane.showMessageDialog(this,m,\\ } } } 4、)Year 类

import javax.swing.*; import java.awt.*;

import java.awt.event.*;

public class Year extends Box implements ActionListener {

int year; JTextField showYear=null; JButton 明年,去年; CalendarPad 日历;

public Year(CalendarPad 日历) {

super(BoxLayout.X_AXIS); showYear=new JTextField(4);

showYear.setForeground(Color.blue);

showYear.setFont(new Font(\

...

提示

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

保存日志.addActionListener(this); 删除日志.addActionListener(this); setLayout(new BorderLayout()); JPanel pSouth=new JPanel(); add(信息条,BorderLayout.NORTH); pSouth.add(保存日志); pSouth.add(删除日志); add(pSouth,BorderLayout.SOUTH); add(new JScrollPane(text),BorderLayout.CENTER); } public void actionPerformed(ActionEvent e) { <

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价: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